Skip to content

Conversation

@wiwa
Copy link
Contributor

@wiwa wiwa commented Jun 30, 2022

Description

Add an extension for the executable runfile in non-Windows OS (.sh) to prevent an issue with ArtifactPrefixConflictException.

When foo:bar is a binary (or test), it will generate a runfile artifact, <bazel-out>/.../foo/bar.
If we also have a subdirectory foo/bar with targets, then there will be a conflict since those targets (e.g. foo/bar:baz) will need the <bazel-out>/.../foo/bar output path, but that is already taken by our first artifact, resulting in Bazel erroring out with com.google.devtools.build.lib.skyframe.ArtifactConflictFinder$ConflictException: com.google.devtools.build.lib.actions.ArtifactPrefixConflictException.

Motivation

Remove conflicts between runfile executables and directory names.

@wiwa wiwa requested review from liucijus and simuons as code owners June 30, 2022 23:05
@wisechengyi
Copy link
Contributor

If it's repro'able here, would recommend adding a test case. but might be good to discuss the idea first to see if it would break any other use cases.

@wiwa
Copy link
Contributor Author

wiwa commented Jun 30, 2022

@wisechengyi added a test, thanks

@wiwa
Copy link
Contributor Author

wiwa commented Jul 14, 2022

@simuons could you take a look? thanks!

@wiwa
Copy link
Contributor Author

wiwa commented Jul 27, 2022

@simuons @liucijus ?

@liucijus
Copy link
Collaborator

Merging, as @simuons is away

@liucijus liucijus merged commit 71d7135 into bazel-contrib:master Jul 28, 2022
@ittaiz
Copy link
Contributor

ittaiz commented Oct 30, 2022

This was a breaking change.
I'm not sure breaking changes are a great idea.
An alternative could have been to add a flag for this.
I know flags are yet more code and cognitive load but OTOH an innocent upgrade just broke an internal feature.
I'll deep dive now to understand the reason but my suspicion is that IJ makes some assumptions based on how java works and now that we don't work like java the feature breaks.

Which sort of leads me to another issue and that is the divergence from how java rules work...

@ittaiz
Copy link
Contributor

ittaiz commented Oct 30, 2022

@wiwa
Copy link
Contributor Author

wiwa commented Nov 1, 2022

I'm not sure the line you linked is the actual issue. That line finds the <target>.runfiles directory, not the <target>.sh script. We don't change the directory name. The <target>.sh script runs the command line for the binary; the linked line(s) seem to replicate (much of) its implementation.

I agree there is likely some assumption on how Java binaries are supposed to be run by the IntelliJ Bazel plugin. We can make an issue to have a flag for this feature?

@ittaiz
Copy link
Contributor

ittaiz commented Nov 2, 2022

There is no <target>.sh script concept in bazel.
There is target-name of a binary rule which is by convention the executable and target-name.runfiles which is the runfiles of the executable.
Because this PR changed the executable to be target-name.sh then Bazel now generates target-name.sh.runfiles.
That is not an opinion it's a fact I've verified locally.

@ittaiz
Copy link
Contributor

ittaiz commented Nov 2, 2022

I think we should:

  1. Revert.
  2. Add this again as opt-in (meaning defaults to previous behavior)
  3. Open bazel side issue to discuss the problem you saw and maybe java will also tackle it

@wiwa
Copy link
Contributor Author

wiwa commented Nov 2, 2022

Thanks for the clarification (and debugging), that sounds entirely reasonable!

@ittaiz
Copy link
Contributor

ittaiz commented Nov 9, 2022

@liucijus @simuons @wiwa how do we progress from here?

@liucijus
Copy link
Collaborator

liucijus commented Nov 9, 2022

I think we should:

1. Revert.

2. Add this again as opt-in (meaning defaults to previous behavior)

3. Open bazel side issue to discuss the problem you saw and maybe java will also tackle it

@ittaiz could you open a reverting PR with an explanation what has been broken?
@wiwa could you take 2 & 3?

@ittaiz
Copy link
Contributor

ittaiz commented Nov 9, 2022

Sure

@wiwa
Copy link
Contributor Author

wiwa commented Nov 9, 2022

Will do! Sorry, been a crazy few days 😅

@ittaiz
Copy link
Contributor

ittaiz commented Nov 9, 2022

Without a doubt...
Hope you're hanging in 🙏🏾
Is it ok if I do the revert PR?

@wiwa
Copy link
Contributor Author

wiwa commented Nov 9, 2022

Yep, revert away.

ittaiz added a commit to ittaiz/rules_scala that referenced this pull request Nov 9, 2022
simuons pushed a commit that referenced this pull request Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants