-
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
Bazel@HEAD crashes if XDG_CACHE_HOME starts with ~/
#21660
Comments
Cc @tetromino FYI @alexeagle as this seems to affect all repos using the bazel-contrib ruleset template. |
Funny bug - a new variation on the theme of #11987 Let me think how to fix this in the least ugly way... |
I think the right behavior is to not shell-expand |
@bazel-io fork 7.2.0 |
The commit fixes the crash in the affected repo. Since the relative path to the output root results in Bazel traversing the root and thus complaining about an infinite symlink expansion, having
|
@fmeum - I think it is a user error to set XDG_CACHE_HOME to the literal string "~/something" and expect the "~" to be expanded by tools downstream. If you set XDG_CACHE_HOME to the literal string "$(cat /etc/passwd)", surely you would not expect tools to shell-expand it and print the contents of /etc/passwd to logs... |
I agree that it's a user error and I also think that this was the right way to fix it, I just wish the error messaging was clearer in this case. I'm also not sure how to improve it though. |
…ME are relative 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 bazelbuild#21660 PiperOrigin-RevId: 615506594 Change-Id: Ice67c8be43cef2812b6dce591bd65b9813e82f5c
…CACHE_HOME are relative (#21796) 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 Co-authored-by: Googler <arostovtsev@google.com> Co-authored-by: Ian (Hee) Cha <heec@google.com>
A fix for this issue has been included in Bazel 7.2.0 RC1. Please test out the release candidate and report any issues as soon as possible. |
Description of the bug:
Since 05ae91f, if
XDG_CACHE_HOME
starts with~/
, the Bazel server crashes at startup (GitHub Actions log follows):Java IO functions appear to resolve
~
while Bazel's native filesystem routines don't.Which category does this issue belong to?
Core
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
No response
Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?No response
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD
?No response
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
Yes, caused by 05ae91f.
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: