NixOS / NixOS/nix

Broken symbolic links in `/nix/var/nix/gcroots/per-user/` are not garbage collected

Open
#7,166 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
17.7k
Forks
2k
Avg merge
1d 16h
Merged PRs (30d)
80

Description

Describe the bug
Broken symbolic links in /nix/var/nix/gcroots/per-user/ are not garbage collected. However, broken symbolic links in /nix/var/nix/gcroots/auto/ are garbage collected. This behavior is not consistent, but it might be intentional. Is that so? If so, why? If not, can we also collect broken symbolic links in the per-user directory?

Steps To Reproduce
The problem arose due to excessive usage of nix-direnv, which creates symbolic links in the per-user category. When nix-direnv profiles are changed, new links are created, and the old ones become broken.

Expected behavior
I do not know what the expected behavior is in general. In my use case, I expected the garbage collector to also collect the symbolic links in the per-user directory.

nix-env --version output
nix-env (Nix) 2.11.0

Additional context
See a corresponding issue at nix-direnv: https://github.com/nix-community/nix-direnv/issues/242.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the broken-link scenario described for /nix/var/nix/gcroots/per-user/ and compare it with garbage collection under /nix/var/nix/gcroots/auto/. Review the linked nix-direnv issue for context; done means the intended behavior is established and the per-user links are either handled consistently or the difference is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.