Open iggy-da opened 1 day ago
The hook _nix_shell_clean_tmpdir may execute rm -rf $TEMPDIR. Observed on Ubuntu 24.04 and MacOS when using nix with direnv.
_nix_shell_clean_tmpdir
rm -rf $TEMPDIR
This happens when this tmpDir variable is assigned the $TEMPDIR path itself, rather than a temp subdirectory.
tmpDir
$TEMPDIR
The $TEMPDIR is then rm -rfed here https://github.com/NixOS/nix/blob/32becc87fef7340600df75ffed6e7c6bc56aa827/src/nix-build/nix-build.cc#L601
rm -rf
This means processes trying to create temporary files inside $TEMPDIR (such as, for example, docker), will fail.
Fix: This tmpDir variable should never be allowed to be the top-level $TEMPDIR.
The hook
_nix_shell_clean_tmpdir
may executerm -rf $TEMPDIR
. Observed on Ubuntu 24.04 and MacOS when using nix with direnv.This happens when this
tmpDir
variable is assigned the$TEMPDIR
path itself, rather than a temp subdirectory.The
$TEMPDIR
is thenrm -rf
ed here https://github.com/NixOS/nix/blob/32becc87fef7340600df75ffed6e7c6bc56aa827/src/nix-build/nix-build.cc#L601This means processes trying to create temporary files inside $TEMPDIR (such as, for example, docker), will fail.
Fix: This
tmpDir
variable should never be allowed to be the top-level$TEMPDIR
.