Don't use local files / headers when using Bazel's sandboxed execution (#25752)

Why are these changes needed?

Wasn't able to build Ray following these instructions : https://docs.ray.io/en/latest/ray-contribute/development.html#building-ray

It fails to run
pip install -e . --verbose # Add --user if you see a permission denied error.

I have a local installation of protobuf via Homebrew and bazel is using its headers against the protobuf that it is pulling into its sandbox. It is a known issue with bazel and one of the workarounds is to block the local dir so it doesn't accidentally pick up the header if someone happens to have it installed locally.

Manually tested by running

bazel build --verbose_failures --sandbox_debug -- //:ray_pkg

Without the fix I would get an error similar to https://gist.github.com/clarng/ff7b7bf7672802d1e3e07b4b509e4fc8
With the fix it builds
This commit is contained in:
clarng 2022-06-14 10:00:30 -07:00 committed by GitHub
parent 1feb702327
commit 922bd1ed69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -192,3 +192,8 @@ build:ubsan --linkopt -fno-sanitize-recover=all
# Import local specific llvm config options, which can be generated by
# ci/env/install-llvm-dependencies.sh
try-import %workspace%/.llvm-local.bazelrc
# Even with sandbox mode bazel prioritizes system headers over the ones in the sandbox.
# It picks up the system headers when someone has protobuf installed via Homebrew.
# Work around for https://github.com/bazelbuild/bazel/issues/8053
build:macos --sandbox_block_path=/usr/local/