Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dpursehouse opened this issue Dec 16, 2017 · 16 comments

Comments

@dpursehouse
Copy link
Contributor

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

@dpursehouse
Copy link
Contributor Author

gerrit $ bazel version
Build label: 0.8.1-homebrew
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Dec 5 19:33:07 2017 (1512502387)
Build timestamp: 1512502387
Build timestamp as int: 1512502387

@dpursehouse
Copy link
Contributor Author

gerrit $ java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

@aehlig
Copy link
Contributor

aehlig commented Dec 18, 2017

@c-parsons as you apparently asked for it, can you take care of triaging this issue? Thanks.

@dpursehouse
Copy link
Contributor Author

Note that the problem can't be reproduced with the exact steps mentioned above any more because that version of jgit is now available on maven. To induce the error, it should be possible to simply change the version to something else that doesn't exist.

@kishankarun
Copy link

kishankarun commented Dec 22, 2017

I am facing the similar issue in windows 7.

I had installed bazel with chocolatey (even i had tried with bazel.exe also)

$ tools/eclipse/project.py

Loading:
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
ERROR: build interrupted
INFO: Elapsed time: 56.353s
FAILED: Build did NOT complete successfully (0 packages loaded)

Even bazel build

$ bazel build gerrit
Loading:
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
ERROR: build interrupted
INFO: Elapsed time: 56.353s
FAILED: Build did NOT complete successfully (0 packages loaded)
$ java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
$ bazel version
Build label: 0.9.0
Build target: bazel-out/x64_windows-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Dec 19 09:32:04 2017 (1513675924)
Build timestamp: 1513675924
Build timestamp as int: 1513675924

@davido
Copy link
Contributor

davido commented Dec 22, 2017

@kishankarun Build of Gerrit Code Review on Windows is bleeding edge and work in progress. It doesn't work yet. I don't think your problem is related to this issue. You may want open a new issue, on Gerrit Code Review issue tracker and not here, as it's not Bazel related (probably).

I guess, that you current problem is workspace-status-command that is per default included and must be overwritten. It would also help, if you try to build a small part of gerrit (basic library) and not the whole world. So try this on Gerrit@HEAD:

  $ bazel build --workspace_status_command=tools/workspace-status.cmd --verbose_failures java/com/google/gerrit/common:server

@davidstanke
Copy link
Contributor

+1 - I just got this issue ("Xcode version must be specified to use an Apple CROSSTOOL") on macOS 10.12.6 Sierra, using Bazel 0.9.0 installed via Homebrew. It was fixed via bazel clean --expunge. (For the record, I'm building a very simple Java app, with a single local_repository external dep.)

@redis-ml
Copy link

redis-ml commented Mar 3, 2018

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

@kishankarun
Copy link

Thanks, @davido, all

@aaaa0441
Copy link

@redisliu thanks for the solution. I am trying to build Angular. You saved my night. 👍

@lizebang
Copy link

@redisliu thanks a lot, good solution.

@gsagula
Copy link

gsagula commented Jun 13, 2019

@redisliu 👍 🥇

@pankajdpatil
Copy link

@redisliu 👍 Thanks!

@jin
Copy link
Member

jin commented Apr 24, 2020

Instead of bazel clean --expunge, you can use bazel sync --configure to not wipe out the external repositories stored in your Bazel output base.

@jin jin closed this as completed Apr 24, 2020
@davido
Copy link
Contributor

davido commented Apr 24, 2020

Instead of bazel clean --expunge, you can use bazel sync --configure to not wipe out your external repository cache.

Gerrit project adjusted: [1] default location of reporsitory cache to be: ~/.gerritcodereview/bazel-cache/repository. So that I would expect, that saying bazel clean --expunge for gerrit project should preserve repositiory cache.

[1] https://gerrit.googlesource.com/gerrit/+/refs/heads/master/.bazelrc#2

@jin
Copy link
Member

jin commented Apr 24, 2020

Gerrit project adjusted: [1] default location of reporsitory cache to be: ~/.gerritcodereview/bazel-cache/repository. So that I would expect, that saying bazel clean --expunge for gerrit project should preserve repositiory cache.

Thanks for pointing it out, sorry I mis-spoke. bazel clean --expunge cleans out the Bazel output_base including the external repositories in it, but does not affect --repository_cache, since that's a directory outside of the output_base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests