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

[CA-drvs] Nix fails to remove directory trees #4858

Closed
fogti opened this issue May 29, 2021 · 4 comments · Fixed by #4928
Closed

[CA-drvs] Nix fails to remove directory trees #4858

fogti opened this issue May 29, 2021 · 4 comments · Fixed by #4928
Assignees
Labels
bug ca-derivations Derivations with content addressed outputs

Comments

@fogti
Copy link
Contributor

fogti commented May 29, 2021

Describe the bug

I got the following error messages:

error: renaming '/nix/store/17zf7d3fh2ajwp9axs12lyh6khy8qdr6-bootstrap-stage0-binutils-wrapper-.drv.chroot/nix/store/a6szxq3w8fxha41z1m7621nmpvwvbh2p-bootstrap-stage0-binutils-wrapper-' to '/nix/store/s3dz0h5cvs1l5yialx32pl8y3z3i4nzg-bootstrap-stage0-binutils-wrapper-': Directory not empty
error (ignored): error: cannot unlink '/tmp/nix-build-xz-5.2.5.drv-0/xz-5.2.5/src/common': Directory not empty
error (ignored): error: cannot unlink '/tmp/nix-build-perl-5.32.1.drv-0/perl-5.32.1/cpan': Directory not empty
error (ignored): error: cannot unlink '/tmp/nix-build-gnum4-1.4.18.drv-0/m4-1.4.18': Directory not empty
error: renaming '/nix/store/phsmcx0dcil8fhbar22k4mdl3b9l446a-expand-response-params.drv.chroot/nix/store/1fa70l9kdbbg8y5hqr4y1svlkhk63ah0-expand-response-params' to '/nix/store/vyb8hzdlrm9x04ydwi5ijax67v7y7d1x-expand-response-params': Directory not empty

Steps To Reproduce

The above mentioned bootstrap-stage0-binutils-wrapper- directory was an aborted previous install, a non-valid store path, which just was still there. It should be possible to reproduce this by creating a fresh store, and build the stdenv with contentAddressedByDefault enabled when importing <nixpkgs> and -j1, terminating it mid-install, and restarting it. Sources shall be substituted from cache.nixos.org, but realizations won't be substituted from there, and cache.ng*.nixos.org won't substitute it bc of #4849.

Expected behavior

Nix should cleanup left-over directories. Currently, this does sometimes fail unexpectedly. Additionally, it seems as if it might try to rebuild something, and doesn't correctly deal with it when the destination is already present (due to CA-derivations).

nix-env --version output

nix-env (Nix) 2.4pre20210529_1f39092

Additional context

@fogti fogti added the bug label May 29, 2021
@fogti
Copy link
Contributor Author

fogti commented May 29, 2021

I suppose this bug wasn't present in Nix 2.4pre20210514_de9e43c and Nix 2.4pre20210506_db6ab75.
https://github.com/NixOS/nix/compare/de9e43c2ea8ac8752d42660c17a7b683682ef38b..1f390922d0e34382265205f6895c2b71c5a8e6f7

@thufschmitt
Copy link
Member

Thanks for reporting this. I also encountered the issue (and I think with some slightly older Nix versions).

There might be two different issues there:

  • The failed unlinking of the build directory seems (sort-of) benign in that the only consequence is that it will leave some garbage on disk
  • The error with the existing and non-empty directory is more serious. I think there’s indeed an issue with Nix not properly detecting that the output path already exists under some mysterious conditions. Maybe there’s some locking missing somewhere.

@thufschmitt thufschmitt self-assigned this May 31, 2021
@thufschmitt thufschmitt added the ca-derivations Derivations with content addressed outputs label May 31, 2021
@fogti
Copy link
Contributor Author

fogti commented May 31, 2021

I don't think it's directly locking related (at least not process-bound locking), as I thought I properly killed (SIGINT, then waiting for termination) the old nix process before starting a new one...

thufschmitt added a commit that referenced this issue Jun 21, 2021
In case a previous interrupted build left a garbage path laying around,
remove it before trying to move the path to its final location.

Fix #4858
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/content-addressed-nix-call-for-testers/12881/118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ca-derivations Derivations with content addressed outputs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants