I’m trying to delete an ISO I built that is currently in the nix store:
I removed the result symbolic link
When running nix-store --delete /nix/store/qrp2lj4dydrr4cyrzgl73afqg7kbdydi-nixos-22.11.20220924.fde244a-x86_64-linux.iso it fails with this error
finding garbage collector roots...
0 store paths deleted, 0.00 MiB freed
error: Cannot delete path '/nix/store/qrp2lj4dydrr4cyrzgl73afqg7kbdydi-nixos-22.11.20220924.fde244a-x86_64-linux.iso' since it is still alive. To find out why, use: nix-store --query --roots
as suggested, I run the command but it returns nothing: nix-store --query --roots /nix/store/qrp2lj4dydrr4cyrzgl73afqg7kbdydi-nixos-22.11.20220924.fde244a-x86_64-linux.iso
If you are sure that nothing depends on it, you can just add the --ignore-liveness, to force deletion. I’ve hit this situation once or twice, might be a bug somewhere but not sure off hand how to triage.
If you wanna be safe before resorting to that, check if a symlink to this output exists anywhere in /nix/var/nix/gcroots
Check for sudo nix-store --gc --print-roots as well! there might be processes directly or indirectly holding a reference. You need sudo to see their PIDs.
That’s a good idea, I’m going to try again.
Although, I’m certain there any PID holding it because that ISO file was generated a few weeks ago, I see no reason for a PID to have it but this deserves trying again.
I found a way to reproduce it, generating a NixOS ISO seems reliable. But it’s super weird, using sudo to find references, there are 2 PID constantly changing that don’t exist when I look for them
solene@t470 ~/d/iso (master)> nix-store --delete /nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso
finding garbage collector roots...
removing stale link from '/nix/var/nix/gcroots/auto/9hvx7qbzij3f59gri8a1hmw53hjckgwg' to '/home/solene/dev/iso/result'
0 store paths deleted, 0.00 MiB freed
error: Cannot delete path '/nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso' since it is still alive. To find out why, use: nix-store --query --roots
solene@t470 ~/d/iso (master) [1]> nix-store --query --roots /nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso
solene@t470 ~/d/iso (master)> sudo nix-store --query --roots /nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso
/proc/13444/environ -> /nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso
/proc/13449/environ -> /nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso
solene@t470 ~/d/iso (master)> sudo nix-store --query --roots /nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso
/proc/13465/environ -> /nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso
/proc/13470/environ -> /nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso
solene@t470 ~/d/iso (master)> sudo nix-store --query --roots /nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso
/proc/13595/environ -> /nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso
/proc/13600/environ -> /nix/store/29qxfyv1gr5qxkvx0y3bs2chhg8a9f46-nixos-22.11.20220924.fde244a-x86_64-linux.iso