Xcode version must be specified to use an Apple CROSSTOOL

Ivan Shelonik picture Ivan Shelonik · Jul 24, 2017 · Viewed 11k times · Source

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

Answer

user8686787 picture user8686787 · Sep 28, 2017
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