Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode version must be specified to use an Apple CROSSTOOL

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

like image 996
Ivan Shelonik Avatar asked Jul 24 '17 09:07

Ivan Shelonik


4 Answers

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
like image 134
user8686787 Avatar answered Nov 12 '22 20:11

user8686787


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.

like image 10
SoMuchNas Avatar answered Nov 12 '22 20:11

SoMuchNas


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.

like image 7
Christopher Parsons Avatar answered Nov 12 '22 18:11

Christopher Parsons


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.

like image 3
mcjoan Avatar answered Nov 12 '22 18:11

mcjoan