Search code examples
bazel

How to start a process (mysql) in Bazel Sandbox (block-network, macos)


I'm trying to start an embedded mysql in my java test.
When I run a basic test which starts up the server with the tag block-network I get:

mysql start failed with error: [ERROR] Can't start server : Bind on unix socket: Operation not permitted 2017-07-24T17:58:59.952051Z 0 [ERROR] Do you already have another mysqld server running on socket: /tmp/5044135838291373301.sock ?

When I remove the tag everything passes. It seems that /tmp is writable.

Full reproduction repository This is on mac os 10.12 with Bazel 0.5.2


Solution

  • Could you please try to build a version of Bazel with this pull-request included (just a one-line change) and see if it helps? Bazel is currently blocking UNIX socket communication on macOS when block-network is specified. This change should allow it. I'm not sure yet whether I want to put this behind a flag (e.g. --sandbox-allow-sockets) or just make it the default behavior, but one way or another, I'll make sure that Bazel will support your use case.