bazel: ccache: FATAL: Could not find compiler "gcc" in PATH

I can’t build any linux targets somehow after I upgraded to Bazel 0.5.4.

ERROR: /usr/local/google/home/ningr/.cache/bazel/_bazel_ningr/5cdbcab7751afe004080d5ce1e95b149/external/gflags_git/BUILD.bazel:7:1: C++ compilation of rule '@gflags_git//:gflags' failed (Exit 1): gcc failed: error executing command 
  (cd /usr/local/google/home/ningr/.cache/bazel/_bazel_ningr/5cdbcab7751afe004080d5ce1e95b149/execroot/__main__ && \
  exec env - \
    PWD=/proc/self/cwd \
  /usr/lib/ccache/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/lib/ccache -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -msse4.1 '-std=c++0x' -MD -MF bazel-out/local-fastbuild/bin/external/gflags_git/_objs/gflags/external/gflags_git/src/gflags_reporting.pic.d '-frandom-seed=bazel-out/local-fastbuild/bin/external/gflags_git/_objs/gflags/external/gflags_git/src/gflags_reporting.pic.o' -fPIC -iquote external/gflags_git -iquote bazel-out/local-fastbuild/genfiles/external/gflags_git -iquote external/bazel_tools -iquote bazel-out/local-fastbuild/genfiles/external/bazel_tools -isystem external/gflags_git -isystem bazel-out/local-fastbuild/genfiles/external/gflags_git -isystem external/bazel_tools/tools/cpp/gcc3 -Ibazel-out/local-fastbuild/genfiles/external/gflags_git/gflags -Wno-sign-compare -Wno-unused-local-typedefs -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/gflags_git/src/gflags_reporting.cc -o bazel-out/local-fastbuild/bin/external/gflags_git/_objs/gflags/external/gflags_git/src/gflags_reporting.pic.o)
ccache: FATAL: Could not find compiler "gcc" in PATH
Target //third_party/s2_geometry:s2_geometry failed to build

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

Found a solution in this thread: https://github.com/bazelbuild/bazel/issues/1322 by: export CC=“/usr/bin/gcc” export CXX=“/usr/bin/g++”

Seemed bazel doesn’t work well with ccache gcc .

I met with the same issue with Bazel-0.13.0 and solved it by downgrading Bazel to 0.12.0.

Another workaround is to set the bazel PATH with --action_env. This is potentially dangerous since in theory, bazel wants isolation from the system environment to ensure build consistency. In practice, this works in my case with bazel 0.5.4.

Example:

bazel build //your/build/target --action_env=PATH=$PATH