bazelbuild/bazel

outputUserRoot doesn't handle backslashes in $USER

Open

#17,961 opened on Apr 3, 2023

View on GitHub
 (2 comments) (3 reactions) (0 assignees)Java (4,465 forks)batch import
P3help wantedteam-OSStype: bug

Repository metrics

Stars
 (25,384 stars)
PR merge metrics
 (Avg merge 22d 20h) (77 merged PRs in 30d)

Description

Description of the bug:

When $USER contains a backslash, the default directory created for the local cache will fail:

ERROR: /home/ul931f/.cache/bazel/_bazel_gusb\ul931f/1feca94333236c9bc795c85d5dbf3d33/external/local_jdk/BUILD.bazel:5:90: invalid escape sequence: \u. Use '\\' to insert '\'.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Probably set $USER to include a backslash, then attempt to do a build. Here's what my $USER var is set to:

$ env | grep USER
USER=gusb\ul931f

This is on an Amazon Linux 2 AMI running in an AWS WorkSpace. The user information is coming via winbind, hence the domain\user pattern in $USER

Which operating system are you running Bazel on?

Amazon Linux 2

What is the output of bazel info release?

release 6.1.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

N/A

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

N/A

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

I work around this by adding the following to my .bazelrc file:

startup --output_user_root=/home/ul931f/.cache/bazel/ul931f

Similarly the following also works:

startup --output_user_root=/home/ul931f/.cache/bazel/_bazel_gusb\\\\ul931f

Contributor guide