-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUNFILES detection in executable scripts is hard #4054
Comments
I think there should be a documented algorithm for resolving an executable's runfiles tree and reference implementations of that algorithm for all builtin Bazel rules. Finding an executable's runfiles turns out be a fairly complex process with correctness implications (e.g., #3919). There are many different environments where the correct runfiles tree must be found. Unsurprisingly, no two current implementations of runfiles tree resolution work the same, so the area is ripe for standardization. |
For people who find this in the future: It seems like finding the first part of |
After some additional investigation, issue #4460 is related |
cc @philwo please triage if this still relevant. |
This is kind of a big deal, as it prevents easily using a java binary as a tool in a genrule if the java binary uses runfiles.
This is with |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale. |
In order for executable rules to be able to properly refer to files that are included as
data
deps, those executables need to know what theRUNFILES
directory is.There are many contexts from which an executable can be invoked, so it's common for the templates of such executable rules to contain boilerplate code that tries to deduce
RUNFILES
with code that looks similar to the following:Blocks of code like this end up sprinkled throughout a project's Bazel codebase, which is (a) not very maintainable, and (b) fragile. And note that the code above only attempts to work on Mac and Linux - with Windows support, it'd look even worse.
Is there any way Bazel could guarantee that
$RUNFILES
will always be set when executable targets are invoked from the following contexts:bazel run
bazel test
genrule
If those guarantees were made, then developers would only have to worry about deducing
RUNFILES
when the script was invoked directly at the command-line, in which caseRUNFILES
is basically<path-to-current-script>.runfiles/
The text was updated successfully, but these errors were encountered: