bazel: After logout and login: Failed to initialize sandbox: getconf failed

Description of the problem:

I ran a bazel build on macOS and got this error:

ERROR: Failed to initialize sandbox: getconf failed

I had just logged out and logged in, so the Bazel daemon existed, but any session state would have changed, if that matters. At first I had to kill with Activity Monitor, the bazel daemon wouldn’t die when being killed with kill -9. After reading #2489 I found that bazel shutdown works.

This is reproducible for me.

Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Run a bazel build
  2. Log out and log in
  3. Run bazel build again

What operating system are you running Bazel on?

macOS 10.14.3

What’s the output of bazel info release?

release 0.23.1

Have you found anything relevant by searching the web?

Just #2489, but @philwo requested I create a new issue.

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

As mentioned above, bazel shutdown works around the problem.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 28
  • Comments: 21 (7 by maintainers)

Most upvoted comments

My OSX WindowsServer crashed couple times. I need to re-login, but all other processes were kept alive. Xcode would fail to build project afterwards. My fix to run “bazel shutdown”. After that all seems to work fine.

I agree this is somewhat unlikely, but I also just ran into this, using Bazel 3.2.0 on Mac OS X 10.15.6 FWIW, so this problem still exists. The bazel shutdown workaround worked. Possibly this Github issue existing is a sufficient fix, since searching for the “Failed to initialize sandbox” error will lead the occasional user who hits it to find this workaround 😄

Happening to me on macOS 11.6.2 with bazel 4.2.2 (homebrew). The workaround was to reboot.

Happened to me also, I used the bazel shutdown command to resolve the issue.

Thanks for the reports folks, I think the next steps here are to:

  1. Generally investigate if this happens with the getconf CLI as well
  2. If it doesn’t, investigate what the difference is between that CLI and the calls bazel does
  3. If it does, investigate if there’s a way around that mentioned in the manpage or anywhere else
  4. If there’s no workaround, investigate if there’s another way to get the variables bazel gets from here, or if we can just replace those variables with something else.

If someone is motivated to take this on, that’s where I would start!

Happening to me on macOS 11.6.2 with bazel 4.2.2 (homebrew). The workaround was to reboot.

Interesting and, ugh, incomplete error messages that don’t say why things failed. How often do you hit this though? Seems like quite a corner case.