bazel: VSCode/Brackets + Santa cause Xcode autoconfiguration to fail on macOS
Description of the problem / feature request:
I got an error when trying to build angular (I’m on the Angular team berchet@)
The error is:
$ bazel test packages/core/test/render3
ERROR: /private/var/tmp/_bazel_berchet/136114fe9f12514cf56a27652da0b4c4/external/local_config_cc/BUILD:50:5: in apple_cc_toolchain rule @local_config_cc//:cc-compiler-darwin_x86_64: Xcode version must be specified to use an Apple CROSSTOOL
ERROR: Analysis of target '//packages/core/test/render3:render3' failed; build aborted: Analysis of target '@local_config_cc//:cc-compiler-darwin_x86_64' failed; build aborted
INFO: Elapsed time: 2.277s
FAILED: Build did NOT complete successfully (34 packages loaded)
ERROR: Couldn't start the build. Unable to run tests
Note: I had this working in the past few weeks (& using multiple times a day).
Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
On a gMac:
- clone the angular repo at https://github.com/angular/angular
- execute
yarn
into the root folder to install deps - execute
bazel test packages/core/test/render3
at the root
yarn
and bazel
must be installed via brew
What operating system are you running Bazel on?
This seems to be the issue, 4 of us ran into this bug after an High Sierra 10.13.3 update
What’s the output of bazel info release
?
bazel version
Build label: 0.9.0-homebrew
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Sun Jul 12 12:24:01 +49936 (1513677414241)
Build timestamp: 1513677414241
Build timestamp as int: 1513677414241
Have you found anything relevant by searching the web?
I have searched the web and my team-mates, misc info
- rebooting help,
xcode-select -s /Applications/Xcode.app/Contents/Developer
before rebooting seems to help,- when you are in a working state, never ever
bazel clean
you could get into the broken state
The error seems to originate in this BUILD file:
# /private/var/tmp/_bazel_berchet/136114fe9f12514cf56a27652da0b4c4/external/local_config_xcode/BUILD
package(default_visibility = ['//visibility:public'])
xcode_config(name = 'host_xcodes')
# Error: Invoking xcode-locator failed, return code 256, stderr: java.io.IOException: Cannot run program "/private/var/tmp/_bazel_berchet/136114fe9f12514cf56a27652da0b4c4/external/local_config_xcode/./xcode-locator-bin" (in directory "/private/var/tmp/_bazel_berchet/136114fe9f12514cf56a27652da0b4c4/external/local_config_xcode"): error=1, Operation not permitted, stdout:
executing /private/var/tmp/_bazel_berchet/136114fe9f12514cf56a27652da0b4c4/external/local_config_xcode/./xcode-locator-bin
fromthe CLI returns
{
"9.2.0": "/Applications/Xcode.app/Contents/Developer",
"9.2": "/Applications/Xcode.app/Contents/Developer",
"9": "/Applications/Xcode.app/Contents/Developer",
}
permissions are -rwxr-xr-x
EDIT: Turned out to be an interacction with VSCode, see the fix below
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 34 (27 by maintainers)
Commits related to this issue
- build: disable bazel-out symlink It causes headaches on MacOS High Sierra, see https://github.com/bazelbuild/bazel/issues/4603 — committed to alexeagle/angular by alexeagle 6 years ago
- build: disable bazel-out symlink (#22375) It causes headaches on MacOS High Sierra, see https://github.com/bazelbuild/bazel/issues/4603 PR Close #22375 — committed to angular/angular by alexeagle 6 years ago
- build: disable bazel-out symlink (#22375) It causes headaches on MacOS High Sierra, see https://github.com/bazelbuild/bazel/issues/4603 PR Close #22375 — committed to angular/angular by alexeagle 6 years ago
- build: disable bazel-out symlink (#22375) It causes headaches on MacOS High Sierra, see https://github.com/bazelbuild/bazel/issues/4603 PR Close #22375 — committed to smdunn/angular by alexeagle 6 years ago
- build: disable bazel-out symlink (#22375) It causes headaches on MacOS High Sierra, see https://github.com/bazelbuild/bazel/issues/4603 PR Close #22375 — committed to leo6104/angular by alexeagle 6 years ago
- Minimize the cost of Skyframe restarts during CC autoconfiguration. Repository functions restart whenever they have to resolve a label due to the way Skyframe currently works. This is problematic be... — committed to bazelbuild/bazel by jmmv 6 years ago
- Allow bazel to create symlinks https://github.com/bazelbuild/bazel/issues/4603 seems to be fixed so these are convenient — committed to alexeagle/rules_nodejs by alexeagle 5 years ago
- Allow Bazel to create symlinks Now that https://github.com/bazelbuild/bazel/issues/4603 is resolved, it's convenient to have them again — committed to alexeagle/rules_nodejs by alexeagle 5 years ago
- Allow Bazel to create symlinks (#527) Now that https://github.com/bazelbuild/bazel/issues/4603 is resolved, it's convenient to have them again — committed to bazelbuild/rules_nodejs by alexeagle 5 years ago
Alright, so it could be that, or… something more crazy: VSCode.
It seems that VSCode holds an open file handle on the
xcode-locator-bin
file as soon as it’s created, which could be blocking executions until whatever VSCode wants to do completes. This may or may not be a problem in itself, or it may be a problem only in combination with Santa.However, @sergiocampama and myself have confirmed that launching and closing VSCode makes the problem appear and vanish consistently.
Add:
"files.exclude": {"bazel-*": true}
to your workspace configuration to ignore the Bazel trees and things will work. (That’s why I had never seen this, because I’ve always had this setting. Removing it made the problem appear pretty quickly.)