Uninstalled packages weren't removed after garbage collection!

I installed ipfetch and github-desktop packages by adding them to my configuration.nix. After some days, I uninstalled them by removing them from my configuration.nix and collected garbage by sudo nix-collect-garbage, sudo nix-collect-garbage -d, and sudo nix-store --gc. Then rebuilt and rebooted the system many times.

But sudo find / -iname "*ipfetch*" found:

/nix/store/m10gprgd4vyn343bp4aschzv9rf9snzr-ipfetch-unstable-2022-03-24.drv
/nix/store/4f8crynngzq0f3wwlcwpvkwfnyfx18q5-nixos-24.05/nixos/pkgs/tools/networking/ipfetch
/nix/store/5dh7wrhq15fa8f0ns9m88a8wm74kywy6-ipfetch-unstable-2022-03-24
/nix/store/5dh7wrhq15fa8f0ns9m88a8wm74kywy6-ipfetch-unstable-2022-03-24/bin/.ipfetch-wrapped
/nix/store/5dh7wrhq15fa8f0ns9m88a8wm74kywy6-ipfetch-unstable-2022-03-24/bin/ipfetch
/nix/store/5dh7wrhq15fa8f0ns9m88a8wm74kywy6-ipfetch-unstable-2022-03-24/usr/share/ipfetch
/nix/store/92xx7lax63r6jqnpfq0i661azlszpz90-system-path/bin/ipfetch
/tmp/ipfetch.YOGuD0
/tmp/ipfetch.aZTQJI
/tmp/ipfetch.ITpGnJ

And sudo find / -iname "*github-desktop*" found:

/nix/store/zkdppgm7b1j7wkqmvixjgwaxas1cd8rq-github-desktop-3.3.12.drv
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/bin/github-desktop
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/bin/.github-desktop-wrapped
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/share/applications/github-desktop.desktop
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/share/lintian/overrides/github-desktop
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/share/icons/hicolor/1024x1024/apps/github-desktop.png
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/share/icons/hicolor/64x64/apps/github-desktop.png
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/share/icons/hicolor/512x512/apps/github-desktop.png
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/share/icons/hicolor/256x256/apps/github-desktop.png
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/share/icons/hicolor/128x128/apps/github-desktop.png
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/share/icons/hicolor/32x32/apps/github-desktop.png
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/share/doc/github-desktop
/nix/store/gybw3nmq9xc4sqqwnad2isq6qmiw90qx-github-desktop-3.3.12/opt/github-desktop
/nix/store/4f8crynngzq0f3wwlcwpvkwfnyfx18q5-nixos-24.05/nixos/pkgs/by-name/gi/github-desktop
/nix/store/92xx7lax63r6jqnpfq0i661azlszpz90-system-path/bin/github-desktop
/nix/store/92xx7lax63r6jqnpfq0i661azlszpz90-system-path/share/applications/github-desktop.desktop
/nix/store/92xx7lax63r6jqnpfq0i661azlszpz90-system-path/share/icons/hicolor/64x64/apps/github-desktop.png
/nix/store/92xx7lax63r6jqnpfq0i661azlszpz90-system-path/share/icons/hicolor/512x512/apps/github-desktop.png
/nix/store/92xx7lax63r6jqnpfq0i661azlszpz90-system-path/share/icons/hicolor/256x256/apps/github-desktop.png
/nix/store/92xx7lax63r6jqnpfq0i661azlszpz90-system-path/share/icons/hicolor/128x128/apps/github-desktop.png
/nix/store/92xx7lax63r6jqnpfq0i661azlszpz90-system-path/share/icons/hicolor/32x32/apps/github-desktop.png
/nix/store/92xx7lax63r6jqnpfq0i661azlszpz90-system-path/share/doc/github-desktop

They are not in my path as expected, but I can run them by their paths I found.

How to solve this type of issue, and how can I find my other shits to clean?

You can run nix-store --query --roots /path (replace path obviously) to find out what gcroots are pointing at it.

But anyway why does this matter? It will get removed eventually if there are no gcroots pointing at it and then you gc (or if automatic gc is enabled, when it runs the next time). No point in obsessing over few bytes here and there.

2 Likes

Well, occasonally I’ll forget about a result symlink of a big VM and then end up wondering why I’ve had to gc for the last 4 regular updates. Keeping an eye on this stuff is nice so you’re not jumped by a goose chase when you need space for something more critical. If some files stay floating around, that’s an indicator you forgot something.

I’m assuming you have, but to be sure, make sure to garbage collect after rebooting, since otherwise the running system will hold garbage collector roots for running stuff. Another quick check is to look for any result symlinks from a nixos-rebuild build.

If neither of that is it, yeah, you’ll have to check the gcroots manually.

2 Likes

Thanks for letting me know.

I already mentioned:

Solved: The Garbage Collector - Nix Pills