bazelbuild/bazel

Bazel fails to start up if $USER is not set plus no valid UID can be retrieved

Open

#16.500 aperta il 18 ott 2022

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)Java (4465 fork)batch import
P2help wantedteam-OSStype: bug

Metriche repository

Star
 (25.384 star)
Metriche merge PR
 (Merge medio 22g 20h) (77 PR mergiate in 30 g)

Descrizione

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

Guida contributor