How do I override the use of /tmp when building with Bazel?

Viewed 3947

I am building a large Bazel project in a cloud VM with /tmp in a small filesystem (~8 GB). Occasionally my build fails with the error Not all outputs were created: the filesystem containing /tmp is at 99% of capacity, and /tmp contains many Bazel build artifacts.

How can I override the temporary directory that Bazel uses? I tried setting the TEMP and TMPDIR environment variables when starting bazel build, but this did not help.

4 Answers

I think you want the --test_tmpdir=<a_path> command line argument to the bazel command.

--test_tmpdir=<a path> default: see description
    Specifies the base temporary directory for 'bazel test' to use.
Related