构建时缺少依赖项@com_google_protobuf//:protobuf_lite

Missing dependencies when building @com_google_protobuf//:protobuf_lite

当尝试从 https://github.com/google/protobuf/(3.4.1 版本)在 OS X 上构建 :protoc 时,我得到以下信息:

$ bazel build @com_google_protobuf//:protobuf_lite

ERROR: <...>/external/com_google_protobuf/BUILD:93:1: undeclared inclusion(s) in rule '@com_google_protobuf//:protobuf_lite':
this rule is missing dependency declarations for the following files included by 'external/com_google_protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc':
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/include/stddef.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/include/__stddef_max_align_t.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/include/stdint.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/include/stdarg.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/include/limits.h'.
```

但是,当构建目标而不是外部存储库时,它会成功。

$ cd <...>/external/com_google_protobuf/
$ bazel build :protobuf_lite

列出的 headers 是系统 headers,所以我遗漏了一些非常明显的东西。

有什么想法吗?

来自 https://github.com/bazelbuild/bazel/issues/2852#issuecomment-295747929 :

设置 BAZEL_SH=/bin/bash 解决了问题。

FWIW 我今天在升级 MacOS 命令行工具后遇到了同样的错误。

对我有用的是 bazel clean --expunge。没有 --expunge 它没有解决问题。