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.
bazel buildbazel build againmacOS 10.14.3
bazel info release?release 0.23.1
Just #2489, but @philwo requested I create a new issue.
As mentioned above, bazel shutdown works around the problem.
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.
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.
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.
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 馃槃
We've been encountering this as well, since WindowServer loves to crash on Catalina for us now.
Most helpful comment
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.