Changing TMPDIR in bazel

37 views
Skip to first unread message

Menny Even Danan

unread,
Jun 30, 2022, 11:17:48 AMJun 30
to bazel-discuss
Hey,
we have a multi-platform bazel setup and local devs environment is also very diversed.
We want to ensure that `TMPDIR` is consistent between all environments and to that, we want to use `--sandbox_tmpfs_path=` flag.

In `.bazelrc`:
```
build --sandbox_tmpfs_path=/tmp1
test --test_tmpdir=/tmp1
common --action_env=TMP=/tmp1 --action_env=TEMP=/tmp1 --action_env=TMPDIR=/tmp1
```

This does not work as we exepct, though. It seems impossible to get TMPDIR to change inside bazel.


Menny Even Danan

unread,
Jun 30, 2022, 11:19:45 AMJun 30
to bazel-discuss
I created a `genrule` to check the temp folder in a build action:
```
~/dev/menny/bazel-tmp-dir (main ✔) bazel build //:env_builder_cmd && cat bazel-bin/env_cmd.txt
INFO: Analyzed target //:env_builder_cmd (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:env_builder_cmd up-to-date:
  bazel-bin/env_cmd.txt
INFO: Elapsed time: 0.033s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
PWD=/home/menny/.cache/bazel/_bazel_menny/33f202e777fb78b580b8a1dd0558ff57/execroot/__main__
TMPDIR=/tmp
TEMP=/tmp1
SHLVL=1
TMP=/tmp1
PATH=/bin:/usr/bin:/usr/local/bin
_=/bin/env
mktemp is /tmp/tmp.AwJMnOpnw3
```

Menny Even Danan

unread,
Jun 30, 2022, 2:47:24 PMJun 30
to bazel-discuss
Even if I explicitly set the variables before executing bazel, I get the same result: `TMPDIR=/tmp1 TEMP=/tmp1 TMP=/tmp1 bazel build //:env_builder_cmd && cat bazel-bin/env_cmd.txt`
Reply all
Reply to author
Forward
0 new messages