[7.2.0] Ensure output root is an absolute path even if $HOME or $XDG_CACHE_HOME are relative #21796
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.
The Bazel server pre-processes the output root via PathFragmentConverter,
which absolutizes paths and expands leading "~" as the home directory. This
can cause the server and the client to treat different directories as output
root, leading to a server crash.
Thus, the client must make the output root absolute. We already do so when
the output root derives from $TEST_TMPDIR (without tilde expansion) in
StartupOptions::StartupOptions. And we do so (with tilde expansion, for
legacy reasons) when the output root derives from the --output_user_root
startup flag passed to the client, see StartupOptions::ProcessArg.
We must do the same when the output root derives from $HOME or
$XDG_CACHE_HOME - without tilde expansion, since it's generally expected
that tools do not perform tilde expansion on paths derived from env
variables (and since tilde expansion on $HOME is meaningless and a
recursive explosion).
Fixes #21660
PiperOrigin-RevId: 615506594
Change-Id: Ice67c8be43cef2812b6dce591bd65b9813e82f5c
Commit f12fc13