3

I have download the git repo containing the c++ tutorial for bazel and I am trying to compile the examples. When performing the command bazel build //main:hello-world, I get the following error:

ccache: error: Failed to create temporary file for /home/username/.ccache/tmp/tmp.cpp_stderr: Read-only file system

Thus I tried several actions: sudo bazel, change permission to /.ccache/tmp/ folder but none has worked. How can I get ride of this error ?

I work on fedora27.

modkin
  • 156
  • 2
  • 11
  • Does this answer your question? [How to get Bazel, ccache, and sandboxing to work together (ccache read only filesystem)](https://stackoverflow.com/questions/52370202/how-to-get-bazel-ccache-and-sandboxing-to-work-together-ccache-read-only-file) – user7610 Sep 18 '20 at 12:52
  • Why do you try to use ccache and Bazel at the same time? You'll use redundant caches, won't you? – hagello Feb 05 '21 at 16:07

2 Answers2

7

The reason for this error is that ccache is used and requires write access ~/.ccache. See in Ondrej's comment to: Bazel building C++ sample with ccache fails

Using --sandbox_writable_path ~/.ccache fixes the issue without disabling the sandbox feature.

sgrefen
  • 141
  • 2
  • 2
3

Solved using the option --strategy=CppCompile=standalone :

bazel build //main:hello-world --strategy=CppCompile=standalone
modkin
  • 156
  • 2
  • 11