47

I try to build tensorflow-serving using bazel but I've encountered some errors during the building

ERROR:/private/var/tmp/_bazel_Kakadu/3f0c35881c95d2c43f04614911c03a57/external/local_config_cc/BUILD:49: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 '//tensorflow_serving/sources/storage_path:file_system_storage_path_source_proto' failed; build aborted.

I've already tried to use bazel clean and bazel clean --expunge but it didn't help and still Bazel doesn't see my xcode (I suppose) but it's completely installed. I even reinstalled it to make sure that all works fine but the error didn't disappeared

My Bazel version is

Build label: 0.5.2-homebrew
Build target: bazel-out/darwin_x86_64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Jul 13 12:29:40 2017 (1499948980)
Build timestamp: 1499948980
Build timestamp as int: 1499948980
KakaduDevs-Mac-mini:serving Kakadu$ 

OS is MacOS Sierra version 10.12.5

What should I do to specify Xcode version in bazel to avoid this error? It seems that the error is common but I haven't found how I can make the bazel build. P.S I'm trying to install tensorflow-serving the way it's explained here. https://tensorflow.github.io/serving/setup

5 Answers 5

112
bazel clean --expunge 
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license
bazel clean --expunge 
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
1
  • If you have a similar problem with other packages besieds tensorflow, repeat first 4 lines and build whatever package you need instead of line 5
    – Valentyn
    Commented Jul 21, 2019 at 15:53
10

Had the same problem, and since I am using a beta version of XCode, I had to find the installation in /Downloads/Xcode-beta.app instead.

Incidentally, the solution for me was to open XCode, go to Preferences, and select the Locations tab. The Command Line Tools drop-down was blank, and I had to press it and select a version (Xcode 9.0 in my case). I then ran bazel clean --expunge and repeated the build process without getting the error. Hope this helps someone.

1
  • 1
    This is the correct answer (or rather the missing piece of the puzzle) for people using CommandLineTools. Thanks! Commented Sep 21, 2018 at 18:15
7

It looks like xcode_configure isn't properly identifying that you have xcode installed. This can sometimes happen if you install xcode but have not yet fully opened it (it may ask you to agree to Terms and Conditions before being fully functional). If this is the problem, you'll need to bazel clean --expunge again after that...

If this doesn't help, you can get some debug information to identify what's gone wrong, by invoking (after a failed build):

cat $(bazel info output_base)/external/local_config_xcode/BUILD

This should contain some comments pertaining to failures in finding your installed xcodes.

1
  • I have agreed to all Terms and Conditions, even tried with opened Xcode project but still the same error . Seems has to find out how to do it manually, thanks for your help that's what i've got after using the line you wrote xcode_config(name = 'host_xcodes') # Error: Running xcodebuild -version failed, return code 72, stderr: xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH , stdout: KakaduDevs-Mac-mini:serving Kakadu$ Commented Jul 25, 2017 at 9:15
3

For me it was a licensing issue for xcodebuild. After running bazel clean --expunge I've tried to run again bazel and I've got the instruction to run sudo xcodebuild -license. I have executed, accepted the license terms, run again bazel clean --expunge and everything has started to work again. Hopefully it solves some of the cases.

1
  • seem as explanation for the most rated answer.
    – zhy
    Commented Jul 20, 2018 at 2:30
1

In order to build objc, Bazel requires that you specify an xcode version - this is usually done automatically by xcode_configure. If that's not working, you can manually specify the xcode version on the command line using the --xcode_version flag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.