Bazel fails to start up if $USER is not set plus no valid UID can be retrieved
#16 500 ouverte le 18 oct. 2022
Métriques du dépôt
- Stars
- (25 384 stars)
- Métriques de merge PR
- (Merge moyen 22j 20h) (77 PRs mergées en 30 j)
Description
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