bazelbuild/bazel
在 GitHub 查看Bazel fails to start up if $USER is not set plus no valid UID can be retrieved
Open
#16,500 创建于 2022年10月18日
P2help wantedteam-OSStype: bug
仓库指标
- Star
- (25,384 star)
- PR 合并指标
- (平均合并 22天 20小时) (30 天内合并 77 个 PR)
描述
Description of the bug:
Bazel tries to get user name to figure out output_user_root even if --output_user_root is passed in. However, GetUserName is a fallible call in an environment where $USER is unset, and getuid or getpwuid don't work properly. Such situation is possible in isolated environments like processed launched by nsjail.
The only option seems to be setting $USER, which is actually unused if --output_user_root is specified. I'd expect setting --output_user_root to be good enough for getting around this.
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
# install nsjail, then
./nsjail -Mo --chroot / --user 99999 --group 99999 -- /bin/sh -i
...
sh-5.1$ bazel
FATAL: $USER is not set, and unable to look up name of current user: (error: 0): Success
Which operating system are you running Bazel on?
Linux 5.18.16-1rodete1-amd64
What is the output of bazel info release?
release 5.3.1
If bazel info release returns development 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 master; git rev-parse HEAD ?
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response