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

Many broken symlinks in /nix/var/nix/gcroots/per-user/username #242

Open
dschrempf opened this issue Oct 13, 2022 · 17 comments
Open

Many broken symlinks in /nix/var/nix/gcroots/per-user/username #242

dschrempf opened this issue Oct 13, 2022 · 17 comments

Comments

@dschrempf
Copy link

Hi!

Whenever an existing nix-direnv profile is changed, the link to the old profile sticks around in /nix/var/nix/gcroots/per-user/username/... and becomes broken because the old profile is deleted by nix-direnv (at least this is the case for me, but see #235).

Is this behavior expected?

At the moment, I delete broken symlinks once every few months, but it is a bit tedious.

I think it is good that the old profile is deleted but I would prefer also deleting the old symlink to the old profile, which will become broken. Is this an option?

Thanks!

@Mic92
Copy link
Member

Mic92 commented Oct 13, 2022

At least in nixos, you can automate cleanup old profiles by doing:

{ nix.gc.automatic = true; }

Than your old links get deleted every day.

@dschrempf
Copy link
Author

dschrempf commented Oct 13, 2022

Weird, this is what I am using, but the direnv links stick.

EDIT: I have to use

cd /nix/var/nix/gcroots/per-user
find . -xtype l -print0 | xargs -0 rm

and a ton of stuff is removed.

@Mic92
Copy link
Member

Mic92 commented Oct 13, 2022

oh, I think you are right. nix-gc does only seem to cleanup profiles and not these gc roots. The current impact is that few inodes for symlinks are wasted. However the references sources are cleaned up.

@dschrempf
Copy link
Author

Yes, I think so.

Funnily enough, the autoamtic garbage collection does remove stale links in /nix/var/nix/gcroots/auto.

@Mic92
Copy link
Member

Mic92 commented Oct 13, 2022

That's why I thought it would also do this for per-user ones...

@dschrempf
Copy link
Author

Do you think I should open a brief issue at NixOS/nix?

@Mic92
Copy link
Member

Mic92 commented Oct 13, 2022

It might good to find out if upstream would be interested in this. Chances are, it leaves the cleanup to the application creating the gcroot in the first place.

@bbenne10
Copy link
Contributor

I think that #246 should resolve this issue. @dschrempf could you try with latest master and report back?

@dschrempf
Copy link
Author

I can confirm that the master version removes gcroot symlink for flakes. I did not test the feature for non-flake repositories! Thank you very much for implementing this feature! If the feature also works for normal repos, we should close it!

@bbenne10
Copy link
Contributor

#246 was tested pretty thoroughly for the use nix usecase, so I think we're going to call this done.
Thanks for the testing (and for the upstream issue, which I think is probably still valid).

@sanerdsher
Copy link

sanerdsher commented Apr 25, 2023

Please reopen. I got the same issue on NixOS from nixos-unstable branch.

~ find -P /nix/var/nix/gcroots/per-user -xtype l 2>/dev/null | TZ=UTC xargs stat --printf="%N\ntime of file birth: %w\n\n"
'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--26d6xg6m11gp22al1gxr1h8zdfmf9j94--source' -> '/etc/nixos/.direnv/flake-inputs//26d6xg6m11gp22al1gxr1h8zdfmf9j94-source'
time of file birth: 2023-04-24 09:21:18.551951038 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--dn0z0jnms4dpa78v3l10phw181dakw4x--source' -> '/etc/nixos/.direnv/flake-inputs//dn0z0jnms4dpa78v3l10phw181dakw4x-source'
time of file birth: 2023-04-24 09:21:18.565951076 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--4xqcsaqhvcvmvlrzx9hn7mwphw5iajav--source' -> '/etc/nixos/.direnv/flake-inputs//4xqcsaqhvcvmvlrzx9hn7mwphw5iajav-source'
time of file birth: 2023-04-24 09:21:18.578951111 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--n0fx19w1fj8bqwvc9pjn38px4jr2ps8r--source' -> '/etc/nixos/.direnv/flake-inputs//n0fx19w1fj8bqwvc9pjn38px4jr2ps8r-source'
time of file birth: 2023-04-24 09:21:18.318950413 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--flj71j7fyv4z4vpn53p836wy6ysbjyfw--source' -> '/etc/nixos/.direnv/flake-inputs//flj71j7fyv4z4vpn53p836wy6ysbjyfw-source'
time of file birth: 2023-04-24 09:21:18.448950762 +0000

~ nix --version
nix (Nix) 2.15.0

~ cat /etc/nixos/.envrc 
#!/usr/bin/env bash

local ver="2.3.0"
local user="nix-community"
local repo="nix-direnv"
local artifact="direnvrc"
local url="https://github.com/raw/${user}/${repo}/${ver}/${artifact}"
local hash="sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="

if ! has nix_direnv_version || ! nix_direnv_version "${ver}"; then
  source_url "${url}" "${hash}"
fi

nix_direnv_watch_file \
  overlays/* \
  pkgs/* \
  shell/*
use flake || use nix

nix store gc doesn't remove such broken links.

@dschrempf
Copy link
Author

Did you run this command as user or as root? I think only sudo nix-collect-garbage -d deletes the profiles of the root user.

@bbenne10
Copy link
Contributor

bbenne10 commented Apr 25, 2023

@dschrempf is right: nix store gc won't do anything here, as you will only remove profiles for your user without sudo (and last I checked there were still some differences between nix-collect-garbage -d and nix store gc, but I couldn't tell you what they were off hand. I'll have to go dig into the differences between those tools soon)

Nix 2.15 should be creating gcroots in $XDG_DATA_DIR/nix/gcroots (which will be ~/.local/share/nix/gcroots), so if these were created both for this user and with this nix version, that is where I would expect them to go. However, it is clearly not for this user. The path ('/nix/var/nix/gcroots/per-user/root/...) states the name of the user for which the gcroot was created. Please try again with sudo.

@sanerdsher
Copy link

Did you run this command <...> as root?

Yes.

I think only sudo nix-collect-garbage -d deletes the profiles of the root user.

I ran this command as root, nothing changed, the broken links remained.

@sanerdsher
Copy link

sanerdsher commented Apr 26, 2023

Nix 2.15 should be creating gcroots in $XDG_DATA_DIR/nix/gcroots (which will be ~/.local/share/nix/gcroots)

By the way, I have other virtual environments that are managed by nix-direnv under another user, but there is no gcroots in that user's home folder in the path you specified.

~ ls -lah /home/sanerdsher/.local/share/nix
total 68K
drwxr-xr-x  2 sanerdsher users    4 Apr  1 11:23 .
drwx------ 32 sanerdsher users   33 Apr 25 15:14 ..
-rw-r--r--  1 sanerdsher users 1.1K Apr 22 07:52 repl-history
-rw-r--r--  1 sanerdsher users  320 Apr  1 11:23 trusted-settings.json

All nix-direnv gcroots are created in /nix/var/nix/gcroots/auto.

~ find -P /nix/var/nix/gcroots/auto -type l 2>/dev/null | TZ=UTC xargs stat --printf="%N\ntime of file birth: %w\n\n"
'/nix/var/nix/gcroots/auto/gmsd2bfd1hff7rk722275xi8prwicgsw' -> '/etc/nixos/.direnv/flake-inputs/2kvv782j3vhfp21ks3xn017cfm77v4rw-source'
time of file birth: 2023-04-24 10:03:16.503710434 +0000

'/nix/var/nix/gcroots/auto/b17hd74im8i8g4zdwqykzi6ws102lcca' -> '/etc/nixos/.direnv/flake-inputs/g9mdif24vvlglyh1f8f7sccw3vcgmxgm-source'
time of file birth: 2023-04-24 10:03:16.194709678 +0000

'/nix/var/nix/gcroots/auto/nqqm1191r9n5dpp7pv9xgynb25gpscgn' -> '/home/sanerdsher/.local/state/home-manager/gcroots/current-home'
time of file birth: 2023-04-24 12:36:22.337084933 +0000

'/nix/var/nix/gcroots/auto/bkshnz180rfbh1cbrs2wcnzwnyyv2msk' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/4w4b4mxfhdc9lf3rsf4qqa9z8xnijbxl-source'
time of file birth: 2023-04-25 12:55:22.951446634 +0000

'/nix/var/nix/gcroots/auto/6ghl0fipf8shm172dd0b7z81jjc0h5gy' -> '/etc/nixos/.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source'
time of file birth: 2023-04-24 10:03:16.691710894 +0000

'/nix/var/nix/gcroots/auto/n8x03qnds6n8i6l9dccdixjjf7diifn1' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source'
time of file birth: 2023-04-22 10:34:57.890263576 +0000

'/nix/var/nix/gcroots/auto/x4kq4x1y37f5sznm4x0jkyyqy8b9ffl8' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/kyskns2vpq0y37djnmd6j96j4fvckzrb-source'
time of file birth: 2023-04-25 12:55:22.567434076 +0000

'/nix/var/nix/gcroots/auto/v0cckf6iyfpff652s6zyh7jfg1p6m8g4' -> '/home/sanerdsher/.local/state/nix/profiles/home-manager-77-link'
time of file birth: 2023-04-24 12:36:22.224083248 +0000

'/nix/var/nix/gcroots/auto/fhghv1psx7bw53rz800jrnxyfv512qhc' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/w7cwn52np84s1vwywdsaxsvx7lcfrcry-source'
time of file birth: 2023-04-22 10:34:57.988265212 +0000

'/nix/var/nix/gcroots/auto/61kqskv4z1nckfk4pwymbcxd2dx0z0rd' -> '/etc/nixos/.direnv/flake-inputs/4w4b4mxfhdc9lf3rsf4qqa9z8xnijbxl-source'
time of file birth: 2023-04-24 10:03:16.797711154 +0000

'/nix/var/nix/gcroots/auto/8w93kbz9bcpslx6cy32nij6kyvjhc1gv' -> '/etc/nixos/.direnv/flake-inputs/3sjyxv7vn9qh90ab4pz79w8cd0bgks6s-source'
time of file birth: 2023-04-24 10:03:17.251712266 +0000

'/nix/var/nix/gcroots/auto/3prz9rkj1mn22yarkdbv471blxkw20bi' -> '/root/.local/state/nix/profiles/channels-1-link'
time of file birth: 2023-04-10 02:27:29.618968986 +0000

'/nix/var/nix/gcroots/auto/a93cji3v3yh0g400psdbjx5bf46x3xxb' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/4w4b4mxfhdc9lf3rsf4qqa9z8xnijbxl-source'
time of file birth: 2023-04-22 10:34:57.922264111 +0000

'/nix/var/nix/gcroots/auto/wawxnwhcj30pigvmxw8fc68p92w1g2w7' -> '/etc/nixos/.direnv/flake-inputs/f27gsyff50limailgapa8nagnasyzynk-source'
time of file birth: 2023-04-24 10:03:17.010711675 +0000

'/nix/var/nix/gcroots/auto/3p03a273a4dpfymgq7vvy1i4xwahp7ia' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/26d6xg6m11gp22al1gxr1h8zdfmf9j94-source'
time of file birth: 2023-04-22 10:34:57.955264661 +0000

'/nix/var/nix/gcroots/auto/6mfgz9s9996hhy6ifzhfmn1zjyia8zlx' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/ki495pvzwdk49sa5lg2xa36wwad1qp4m-source'
time of file birth: 2023-04-25 12:55:22.719439047 +0000

'/nix/var/nix/gcroots/auto/4zwqcicg5d47b9vgwm3jiriirldx9v1q' -> '/etc/nixos/.direnv/flake-inputs/4rrx39y879dy0026zmvwn9mbq9g7d6xp-source'
time of file birth: 2023-04-24 10:03:17.505712889 +0000

'/nix/var/nix/gcroots/auto/2m8wm8j83xbdp2b6wmrgd0bgy8qd4r75' -> '/root/.cache/nix/flake-registry.json'
time of file birth: 2023-04-24 09:25:07.291707471 +0000

'/nix/var/nix/gcroots/auto/i7kb6qrjlnrs041dxx4xb11hpqq0zm3h' -> '/nix/var/nix/profiles/per-user/root/channels-21-link'
time of file birth: 2023-03-04 19:49:45.616524920 +0000

'/nix/var/nix/gcroots/auto/gp9mw4mg62rhv89f83ff1n0i01gj88y2' -> '/etc/nixos/.direnv/flake-inputs/6r93yb0m2nx09m6zpmrpmcdpg0m6irln-source'
time of file birth: 2023-04-24 10:03:17.330712460 +0000

'/nix/var/nix/gcroots/auto/d65rshzxc0kxwgz7ibniqc75isksgc6h' -> '/nix/var/nix/profiles/system-308-link'
time of file birth: 2023-04-24 12:35:43.859504418 +0000

'/nix/var/nix/gcroots/auto/fn9wpv98r9v3r93ag1k4g258as71lv5z' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source'
time of file birth: 2023-04-25 12:55:22.849443298 +0000

'/nix/var/nix/gcroots/auto/4hmlf9f2bl3w8k4dfdwmw4828gqqqhj3' -> '/etc/nixos/.direnv/flake-inputs/r2ip1850igy8kciyaagw502s3c6ph1s4-source'
time of file birth: 2023-04-24 10:03:16.594710657 +0000

'/nix/var/nix/gcroots/auto/gryjlwqx70hqkr637cq9zhfjpdvm33r5' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/ki495pvzwdk49sa5lg2xa36wwad1qp4m-source'
time of file birth: 2023-04-22 10:34:57.858263042 +0000

'/nix/var/nix/gcroots/auto/vpb4yxd2hhf5nvxbjpzxn2kq9rfb9ibs' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa'
time of file birth: 2023-04-25 12:55:22.254423840 +0000

'/nix/var/nix/gcroots/auto/h4dcsrhiklfr21v5p4jank5543gkca46' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa'
time of file birth: 2023-04-22 10:34:57.743261123 +0000

'/nix/var/nix/gcroots/auto/il5czdhh60xgaf6mdhdrvr6mj9mj5g4j' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/kyskns2vpq0y37djnmd6j96j4fvckzrb-source'
time of file birth: 2023-04-22 10:34:57.826262508 +0000

'/nix/var/nix/gcroots/auto/pcb1mykkjm68z7zr6ar76b3fflg20ic3' -> '/etc/nixos/.direnv/flake-inputs/kyskns2vpq0y37djnmd6j96j4fvckzrb-source'
time of file birth: 2023-04-24 10:03:16.378710128 +0000

'/nix/var/nix/gcroots/auto/9dh09yhnfbbyc66w4pa3j59mnnf8k8nx' -> '/nix/var/nix/profiles/per-user/sanerdsher/profile-41-link'
time of file birth: 2023-04-24 13:34:09.822351226 +0000

'/nix/var/nix/gcroots/auto/zycfrxz02d5jskzp7dkv7x8xkmjbsn41' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/qykmmh8vicxz1kf6phsavpfzp0bj5lbd-source'
time of file birth: 2023-04-25 12:55:23.157453358 +0000

'/nix/var/nix/gcroots/auto/hwslv8zm8169qkj1n8cp6yhszjvar1x5' -> '/etc/nixos/.direnv/flake-inputs/0na3q5kjqv53icivlh8hh3b2inyyh9xw-source'
time of file birth: 2023-04-24 10:03:16.137709538 +0000

'/nix/var/nix/gcroots/auto/4ld3b9y9281n23aczf0f4yn035p3j1yd' -> '/etc/nixos/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa'
time of file birth: 2023-04-24 10:03:15.121707053 +0000

'/nix/var/nix/gcroots/auto/9lf6jnfwm0pqa0gvi44idajcxxzn0ggl' -> '/etc/nixos/.direnv/flake-inputs/4jgird7khlkqr6gddl7b9rjn3953z4vq-source'
time of file birth: 2023-04-24 10:03:16.263709846 +0000

'/nix/var/nix/gcroots/auto/0387r59fpzjzmh7lqlyj2xmm3xghhjsa' -> '/etc/nixos/.direnv/flake-inputs/i5ipw8rvj1fvdaj01bqzc0dpw9irrb4h-source'
time of file birth: 2023-04-24 10:03:16.888711377 +0000

'/nix/var/nix/gcroots/auto/d7wsciyfwabrx4argj81ch08dgajcjvw' -> '/etc/nixos/.direnv/flake-inputs/216dq8q3hxbf7qnc61x6i907vgb31dvk-source'
time of file birth: 2023-04-24 10:03:17.151712021 +0000

'/nix/var/nix/gcroots/auto/f1hc6df2bn0a14hpw96p2cj2jvsxqi2j' -> '/home/sanerdsher/.cache/nix/flake-registry.json'
time of file birth: 2023-04-25 04:49:53.024117433 +0000

'/nix/var/nix/gcroots/auto/mqnlcjh5rxr6gllmkxpg3nf9zgj11zwr' -> '/home/sanerdsher/Projects/<...>/.direnv/flake-inputs/26d6xg6m11gp22al1gxr1h8zdfmf9j94-source'
time of file birth: 2023-04-25 12:55:23.053449965 +0000

'/nix/var/nix/gcroots/auto/ysmag3ak13h9frjss5n7rggfyvz538r3' -> '/etc/nixos/.direnv/flake-inputs/s35rwprvrg26vgzi5clvmp1jvcvba5b8-source'
time of file birth: 2023-04-24 10:03:17.415712668 +0000

But if nix-direnv was run as root, then for some reason gcroots are also duplicated in /nix/var/nix/gcroots/per-user.

~ find -P /nix/var/nix/gcroots/per-user -type l 2>/dev/null | TZ=UTC xargs stat --printf="%N\ntime of file birth: %w\n\n"
'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--2kvv782j3vhfp21ks3xn017cfm77v4rw--source' -> '/etc/nixos/.direnv/flake-inputs//2kvv782j3vhfp21ks3xn017cfm77v4rw-source'
time of file birth: 2023-04-24 09:21:18.385950592 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--profile--a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa' -> '/etc/nixos/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa'
time of file birth: 2023-04-24 09:21:17.437948048 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--26d6xg6m11gp22al1gxr1h8zdfmf9j94--source' -> '/etc/nixos/.direnv/flake-inputs//26d6xg6m11gp22al1gxr1h8zdfmf9j94-source'
time of file birth: 2023-04-24 09:21:18.551951038 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--4jgird7khlkqr6gddl7b9rjn3953z4vq--source' -> '/etc/nixos/.direnv/flake-inputs//4jgird7khlkqr6gddl7b9rjn3953z4vq-source'
time of file birth: 2023-04-24 09:21:18.341950474 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--3sjyxv7vn9qh90ab4pz79w8cd0bgks6s--source' -> '/etc/nixos/.direnv/flake-inputs//3sjyxv7vn9qh90ab4pz79w8cd0bgks6s-source'
time of file birth: 2023-04-24 09:21:18.536950998 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--dn0z0jnms4dpa78v3l10phw181dakw4x--source' -> '/etc/nixos/.direnv/flake-inputs//dn0z0jnms4dpa78v3l10phw181dakw4x-source'
time of file birth: 2023-04-24 09:21:18.565951076 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--r2ip1850igy8kciyaagw502s3c6ph1s4--source' -> '/etc/nixos/.direnv/flake-inputs//r2ip1850igy8kciyaagw502s3c6ph1s4-source'
time of file birth: 2023-04-24 09:21:18.396950622 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--i5ipw8rvj1fvdaj01bqzc0dpw9irrb4h--source' -> '/etc/nixos/.direnv/flake-inputs//i5ipw8rvj1fvdaj01bqzc0dpw9irrb4h-source'
time of file birth: 2023-04-24 09:21:18.434950724 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--4xqcsaqhvcvmvlrzx9hn7mwphw5iajav--source' -> '/etc/nixos/.direnv/flake-inputs//4xqcsaqhvcvmvlrzx9hn7mwphw5iajav-source'
time of file birth: 2023-04-24 09:21:18.578951111 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--g9mdif24vvlglyh1f8f7sccw3vcgmxgm--source' -> '/etc/nixos/.direnv/flake-inputs//g9mdif24vvlglyh1f8f7sccw3vcgmxgm-source'
time of file birth: 2023-04-24 09:21:18.330950445 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--4w4b4mxfhdc9lf3rsf4qqa9z8xnijbxl--source' -> '/etc/nixos/.direnv/flake-inputs//4w4b4mxfhdc9lf3rsf4qqa9z8xnijbxl-source'
time of file birth: 2023-04-24 09:21:18.421950689 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--yj1wxm9hh8610iyzqnz75kvs6xl8j3my--source' -> '/etc/nixos/.direnv/flake-inputs//yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source'
time of file birth: 2023-04-24 09:21:18.407950651 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--216dq8q3hxbf7qnc61x6i907vgb31dvk--source' -> '/etc/nixos/.direnv/flake-inputs//216dq8q3hxbf7qnc61x6i907vgb31dvk-source'
time of file birth: 2023-04-24 09:21:18.491950877 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--kyskns2vpq0y37djnmd6j96j4fvckzrb--source' -> '/etc/nixos/.direnv/flake-inputs//kyskns2vpq0y37djnmd6j96j4fvckzrb-source'
time of file birth: 2023-04-24 09:21:18.351950501 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--n0fx19w1fj8bqwvc9pjn38px4jr2ps8r--source' -> '/etc/nixos/.direnv/flake-inputs//n0fx19w1fj8bqwvc9pjn38px4jr2ps8r-source'
time of file birth: 2023-04-24 09:21:18.318950413 +0000

'/nix/var/nix/gcroots/per-user/root/etc-nixos-.direnv-flake--inputs--flj71j7fyv4z4vpn53p836wy6ysbjyfw--source' -> '/etc/nixos/.direnv/flake-inputs//flj71j7fyv4z4vpn53p836wy6ysbjyfw-source'
time of file birth: 2023-04-24 09:21:18.448950762 +0000

Just in case, let me clarify that not all of the links found with these two commands are broken, because the search here was run to find all the links. Only the ones listed in this post are broken.

@dschrempf
Copy link
Author

dschrempf commented Apr 26, 2023

Hm, interesting. I can confirm that a broken link in /nix/var/nix/gcroots/per-user/root/ is not deleted by sudo nix-collect-garbage -d (user links are deleted). This seems more like an upstream issue to me.

I also observe that nix-direnv links are created in the auto directory, and not the XDG_DATA_DIR one. I am using nix-2.15.

However, since I only use nix-direnv as a user, I do not actively experience those problems. I have no links in the gcroots/per-user/ directories, and the auto ones get garbage collected perfectly fine. Nevertheless, we should fix these, if others also experience them. How should we proceed?

EDIT: I checked once more, and broken links pointing from gcroots/per-user/root into the Nix store are handled during garbage collection:

skipping invalid root from '/nix/var/nix/gcroots/per-user/root/my-root' to '/nix/store/sxgg5crhb2krygcpfyx3mzgv1xajqs91-nix-run-rofi'

It seems like I do not know well enough how garbage collection works :-)!

@Mic92 Mic92 reopened this Apr 26, 2023
@bbenne10
Copy link
Contributor

bbenne10 commented Apr 27, 2023

I could be wrong - but this looks to be the same bug that @dschrempf opened upstream to me?
We don't create those files specifically and I'm not sure how we can do much besides walk over all of the files in /nix/var/nix/gcroots/per-user/$USER and test if any of them are broken. Unfortunately, the possibility that that may take non-trivial time makes it difficult for me to recommend, as it interferes with the "normal" usage patterns of nix-direnv.

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

No branches or pull requests

4 participants