make inferred workspace dir consistent with actual one in builds #129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I want to make the workspace path you get when you look at
$BUILD_WORKSPACE_DIRECTORY
inside the target you're running, be consistent with the value you get if you do$(dirname "$(dirname "${BASH_SOURCE[0]}")")
in atools/bazel
script. I'm using the latter form of this as part of a startup option in my wrapper.I am using the tools/bazel script to
$BAZEL_REAL run
the full wrapper target, which takes the rest of the args, does some logging, and invokes BAZEL_REAL again with the original args. But it also needs to set that startup option when it does so, to avoid thrashing the server. To do so it uses BUILD_WORKSPACE_DIRECTORY.What I noticed is that it was thrashing the server anyway. When I dug in, it turned out the issue was that inside tools/bazel it was passing
--host_jvm_args=-Djavax.net.ssl.trustStore=/Users/geoff/proj/./cacerts`
But inside the target running via bazel run, it was passing
--host_jvm_args=-Djavax.net.ssl.trustStore=/Users/geoff/proj/cacerts`
Even though they're logically the same file, bazel doesn't realize that, especially when the path is being passed to an arbitrary JVM flag. So it restarts the server each time.
Removing the leading
./
in the constant prevents the server restarts, and seems safe because that constant is only ever used inos.path.join()
which is aware of how to combine path components.I also included a test to show the difference, but you can remove it if you think it's silly.