Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix-shell /tmp/ directories deleted while still in use #299272

Open
samuela opened this issue Mar 26, 2024 · 7 comments
Open

nix-shell /tmp/ directories deleted while still in use #299272

samuela opened this issue Mar 26, 2024 · 7 comments

Comments

@samuela
Copy link
Member

samuela commented Mar 26, 2024

Issue description

I occasionally encounter errors such as

[skainswo@bitbop-proxy-arm:~/dev/bitbop/cherami]$ cargo build                                                                                               
   Compiling libc v0.2.152                                                                                                                                  
   Compiling autocfg v1.1.0                                                                                                                                 
error: couldn't create a temp dir: No such file or directory (os error 2) at path "/tmp/nix-shell.s7uxvf/rustcoG5wgG"                                       
                                                                                                                                                            
error: could not compile `libc` (build script) due to previous error                                                                                        
warning: build failed, waiting for other jobs to finish...                                                                                                  
error: couldn't create a temp dir: No such file or directory (os error 2) at path "/tmp/nix-shell.s7uxvf/rustcuBk6VG"                                       
                                                                                                                                                            
error: could not compile `autocfg` (lib) due to previous error                                                                                              

in nix-shell sessions that have been open for a while.

Steps to reproduce

Open a nix-shell and leave it running for a few days. Then attempt to build some rust code.

Technical details

 - system: `"aarch64-linux"`
 - host os: `Linux 6.1.75, NixOS, 23.11 (Tapir), 23.11.5541.56528ee42526`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos-23.11"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@lolbinarycat
Copy link
Contributor

according to this reddit comment, nixos uses systemd's defaults, which is to delete tempfiles after 10 days.

@lolbinarycat
Copy link
Contributor

however, according to the comments on #96753 (and looking at my own /tmp), this file is actually ignored.

@samuela
Copy link
Member Author

samuela commented May 2, 2024

Shouldn't the temp directory be kept as long as it's actively in use by a shell?

@lolbinarycat
Copy link
Contributor

"actively in use by a shell" isn't something that systemd-tmpfiles can quantify. the correct way to keep tempfiles from being deleted is to periodically bump their mtime.

@samuela
Copy link
Member Author

samuela commented May 4, 2024

the correct way to keep tempfiles from being deleted is to periodically bump their mtime

then nix-shell should do that?

@lolbinarycat
Copy link
Contributor

yes, it should. i was explaining why this is the fault of nix, not systemd-tmpfiles

@samuela
Copy link
Member Author

samuela commented May 7, 2024

yes, it should. i was explaining why this is the fault of nix, not systemd-tmpfiles

ah gotcha, i misunderstood the implication in your prior message. thanks for clarifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants