bazel: Bazel 0.8.1: Build fails with "Xcode version must be specified to use an Apple CROSSTOOL" on OSX High Sierra

This is similar to #3063 but not quite the same so I’m adding a new issue rather than commenting on that one again. CC @c-parsons as you were asking me about it before.

While building gerrit, the build failed due to a 404 on one of the dependency downloads. Then, on subsequent builds it failed with Xcode version must be specified to use an Apple CROSSTOOL. It only succeeds (or rather, fails again but with the expected error) after cleaning.

  1. The initial failure caused by 404 when downloading jgit library (seems to have not propagated on maven central yet):
gerrit $ bazel build gerrit
............
ERROR: /Users/dpursehouse/git/gerrit/lib/jgit/org.eclipse.jgit/BUILD:3:1: no such package '@jgit_lib//jar': failed /usr/bin/python /Users/dpursehouse/git/gerrit/tools/download_file.py -o /private/var/tmp/_bazel_dpursehouse/af01e59a244d19667aa266607f080c5a/external/jgit_lib/jar/org.eclipse.jgit-4.9.2.201712150930-r.jar -u MAVEN_CENTRAL:/org/eclipse/jgit/org.eclipse.jgit/4.9.2.201712150930-r/org.eclipse.jgit-4.9.2.201712150930-r.jar -v a3a2d1df793245ebfc7322db3c2b9828ee184850 --unsign: Download http://repo1.maven.org/maven2/org/eclipse/jgit/org.eclipse.jgit/4.9.2.201712150930-r/org.eclipse.jgit-4.9.2.201712150930-r.jar
curl: (22) The requested URL returned error: 404 Not Found
error using curl: Command '['curl', '--proxy-anyauth', '-ksSfLo', '/Users/dpursehouse/.gerritcodereview/buck-cache/downloaded-artifacts/org.eclipse.jgit-4.9.2.201712150930-r.jar-a3a2d1df793245ebfc7322db3c2b9828ee184850', 'http://repo1.maven.org/maven2/org/eclipse/jgit/org.eclipse.jgit/4.9.2.201712150930-r/org.eclipse.jgit-4.9.2.201712150930-r.jar']' returned non-zero exit status 22
 and referenced by '//lib/jgit/org.eclipse.jgit:jgit'
ERROR: Analysis of target '//:gerrit' failed; build aborted: Loading failed
INFO: Elapsed time: 8.959s
FAILED: Build did NOT complete successfully (68 packages loaded)
  1. Subsequent build fails with Xcode version ... error:
gerrit $ bazel build gerrit
ERROR: /private/var/tmp/_bazel_dpursehouse/af01e59a244d19667aa266607f080c5a/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 '//:gerrit' failed; build aborted: Analysis of target '@local_config_cc//:cc-compiler-darwin_x86_64' failed; build aborted
INFO: Elapsed time: 0.399s
FAILED: Build did NOT complete successfully (14 packages loaded)
    currently loading: gerrit-util-http ... (2 packages)
  1. Run it again and see that it still fails with the Xcode error:
gerrit $ bazel build gerrit
ERROR: /private/var/tmp/_bazel_dpursehouse/af01e59a244d19667aa266607f080c5a/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 '//:gerrit' failed; build aborted: Analysis of target '@local_config_cc//:cc-compiler-darwin_x86_64' failed; build aborted
INFO: Elapsed time: 0.183s
FAILED: Build did NOT complete successfully (0 packages loaded)
    currently loading: lib/lucene
  1. Clean and try again, then it fails with the original (and expected) error
gerrit $ bazel clean --expunge
INFO: Starting clean (this may take a while). Consider using --expunge_async if the clean takes more than several minutes.
gerrit $ bazel build gerrit
............
ERROR: /Users/dpursehouse/git/gerrit/lib/jgit/org.eclipse.jgit/BUILD:3:1: no such package '@jgit_lib//jar': failed /usr/bin/python /Users/dpursehouse/git/gerrit/tools/download_file.py -o /private/var/tmp/_bazel_dpursehouse/af01e59a244d19667aa266607f080c5a/external/jgit_lib/jar/org.eclipse.jgit-4.9.2.201712150930-r.jar -u MAVEN_CENTRAL:/org/eclipse/jgit/org.eclipse.jgit/4.9.2.201712150930-r/org.eclipse.jgit-4.9.2.201712150930-r.jar -v a3a2d1df793245ebfc7322db3c2b9828ee184850 --unsign: Download http://repo1.maven.org/maven2/org/eclipse/jgit/org.eclipse.jgit/4.9.2.201712150930-r/org.eclipse.jgit-4.9.2.201712150930-r.jar
curl: (22) The requested URL returned error: 404 Not Found
error using curl: Command '['curl', '--proxy-anyauth', '-ksSfLo', '/Users/dpursehouse/.gerritcodereview/buck-cache/downloaded-artifacts/org.eclipse.jgit-4.9.2.201712150930-r.jar-a3a2d1df793245ebfc7322db3c2b9828ee184850', 'http://repo1.maven.org/maven2/org/eclipse/jgit/org.eclipse.jgit/4.9.2.201712150930-r/org.eclipse.jgit-4.9.2.201712150930-r.jar']' returned non-zero exit status 22
 and referenced by '//lib/jgit/org.eclipse.jgit:jgit'
ERROR: Analysis of target '//:gerrit' failed; build aborted: Loading failed
INFO: Elapsed time: 8.886s
FAILED: Build did NOT complete successfully (63 packages loaded)

OS: OSX High Sierra 10.13.2

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

FYI: I encountered similar issue recently, which got fixed with:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license
bazel clean --expunge

Reference: https://stackoverflow.com/questions/45276830/xcode-version-must-be-specified-to-use-an-apple-crosstool