-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Make original working directory available to commands that are run #3635
Conversation
I like this solution. Seems useful to me. |
@ulfjack, what do you think about this? |
I'm not sure it's the right way to go, but it's a simple change and doesn't require any configuration. Seems reasonable. Needs test(s) and documentation. |
Happy to do that. |
@ianthehat I'd suggest adding a shell integration test that uses "bazel run" to run a shell script that prints the contents of $BAZEL_PWD and ensure that the output is equal to the current $PWD in the test. I think you could add it to this one: https://github.com/bazelbuild/bazel/blob/master/src/test/shell/integration/run_test.sh The existing test methods should serve as examples on how it generally works. Feel free to ask here if you need more information. |
Friendly ping @ianthehat |
I basically abandoned this approach, because it still does not solve all the problems (we really need to release the lock as well). Instead I have switched to using the bazel-run script, and recommending to people they download it from the repository and put it on their path somewhere. It's an annoying extra step, to have to tell people to do, and I really dislike telling people to curl a bash script, but it unlocks a lot more functionality.
|
So that means that this pull request should be closed, correct? |
Sure, unless someone else wants to take it on, I have no plans to add the test myself at this point |
This adds the environment variable BAZEL_PWD for things invoked with
bazel run
This allows programs that you run to access the original path it was run from.
It enables you to write rules to run code modification tools (refactoring, formatting, build file generation) without changing anything fundamental.
You can see an example of using it here, to run the gazelle build file generator.
See #3325 for the discussion that led to this suggestion