bazel icon indicating copy to clipboard operation
bazel copied to clipboard

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

Open kastiglione opened this issue 7 years ago • 22 comments

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.

kastiglione avatar Mar 11 '19 23:03 kastiglione

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.

jmmv avatar Mar 14 '19 09:03 jmmv

I'm also quite surprised, that the Bazel server survives a logout - I always thought that logging out on macOS causes all processes launched during that user session to be terminated.

We should of course fix this and it's probably not too difficult.

philwo avatar Mar 14 '19 11:03 philwo

I almost never logout, this is definitely an unlikely corner case. I created this issue just to document it, I personally don't need a fix.

kastiglione avatar Mar 14 '19 14:03 kastiglione

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.

OleksiyA avatar Jun 05 '19 03:06 OleksiyA

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 😄

evanj avatar Jul 24 '20 18:07 evanj

We've been encountering this as well, since WindowServer loves to crash on Catalina for us now.

brentleyjones avatar Jul 24 '20 19:07 brentleyjones

Just hit this on macos catalina 10.15.7 and bazel 4.0.0.

pcj avatar Jan 30 '21 23:01 pcj

Just encountered this as well on MacOS Mojave 10.14.3 and bazel 3.7.1

pawaramol avatar Feb 11 '21 23:02 pawaramol

Encountered this on macos 10.15.7, bazel 3.1.0

bigbangvn avatar Feb 22 '21 02:02 bigbangvn

Add a data point, macOS 10.15.7, bazel 4.0.0-homebrew

xhuoroku avatar Jun 08 '21 06:06 xhuoroku

This one is still happening on Big Sur

jerrymarino avatar Sep 08 '21 18:09 jerrymarino

Present on Bazel 4.2.0 on macOS 11.2.2

jschaf avatar Nov 28 '21 04:11 jschaf

Happened to me today on bazel 4.2.1-homebrew on macOS 11.6.1

cmey avatar Dec 03 '21 14:12 cmey

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

fernandoacorreia avatar Jan 06 '22 19:01 fernandoacorreia

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!

keith avatar Jan 10 '22 18:01 keith

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.

guillaumep avatar Jun 28 '22 14:06 guillaumep

macOS 12.4 and bazel 5.2.0

cassandrasandquist avatar Jul 20 '22 18:07 cassandrasandquist

macOS 13.0 and bazel 5.0.0

zhuangya avatar Feb 03 '23 10:02 zhuangya

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.

bazel shutdown worked for me

dqhieu avatar Apr 26 '23 04:04 dqhieu

Same for macOS 13.2.1 (22D68) && bazel 6.2.1, bazel shutdown didn't help. upd: fixed after system restart.

nmtitov avatar Jun 13 '23 13:06 nmtitov

Encountered this today on macOS 12.6.3 and bazel 5.4.0. Solved using bazel shutdown fix.

alexcstaley avatar Dec 21 '23 17:12 alexcstaley

This bug is still reproducible by logging out and in.

BYVoid avatar Jun 24 '24 14:06 BYVoid

We've hit this a few times, definitely still an issue +1. Only a restart seems to fix in the cases we've hit.

luispadron avatar Jul 11 '24 18:07 luispadron

I faced a similar issue. When I logged out and logged back in, the same error message appeared with bazel build. Running bazel shutdown resolved the issue.

macos: 15.0.1 (24A348) bazel: bazel 7.4.0-homebrew

aaazzz avatar Nov 07 '24 08:11 aaazzz

Got the same issue with the same error message : ERROR: Failed to initialize sandbox: getconf failed bazel shutdown solves the problem macos: 14.6.1 bazel : 6.5.0

Sacha924 avatar Nov 21 '24 09:11 Sacha924

Got the same issue with the same error message as @Sacha924 . bazel shutdown fixed it.

mtullalizardi avatar Mar 04 '25 21:03 mtullalizardi

This is easily reproducible on macOS if you log out and log back in after having made a build. It seems the bazel server doesn't handle this well

luispadron avatar Mar 04 '25 21:03 luispadron