From 922bd1ed696c0ad157d6f81f81ff115a5e4b9106 Mon Sep 17 00:00:00 2001 From: clarng Date: Tue, 14 Jun 2022 10:00:30 -0700 Subject: [PATCH] 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 --- .bazelrc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.bazelrc b/.bazelrc index e1c37ce4c..c176b4171 100644 --- a/.bazelrc +++ b/.bazelrc @@ -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/