巴泽尔 无法创建临时文件

bazel Failed to create temporary file

本文关键字:创建 临时文件      更新时间:2023-10-16

我已经下载了包含 bazel 的 c++ 教程的 git 存储库,我正在尝试编译示例。执行命令bazel build //main:hello-world时,出现以下错误:

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

因此,我尝试了几种操作:sudo bazel,将权限更改为/.ccache/tmp/文件夹,但没有一个有效。我怎样才能摆脱这个错误?

我在 fedora27 上工作。

此错误的原因是使用了 ccache 并且需要写访问权限 ~/.ccache。请参阅Ondrej的评论:Bazel使用ccache构建C++示例失败

使用 --sandbox_writable_path ~/.ccache 在不禁用沙盒功能的情况下修复了此问题。

使用选项 --strategy=CppCompile=standalone 解决:

bazel build //main:hello-world --strategy=CppCompile=standalone