-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Comments
At least in nixos, you can automate cleanup old profiles by doing: { nix.gc.automatic = true; } Than your old links get deleted every day. |
Weird, this is what I am using, but the direnv links stick. EDIT: I have to use
and a ton of stuff is removed. |
oh, I think you are right. |
Yes, I think so. Funnily enough, the autoamtic garbage collection does remove stale links in |
That's why I thought it would also do this for per-user ones... |
Do you think I should open a brief issue at NixOS/nix? |
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. |
I think that #246 should resolve this issue. @dschrempf could you try with latest master and report back? |
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! |
#246 was tested pretty thoroughly for the |
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://raw.githubusercontent.com/${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
|
Did you run this command as user or as root? I think only |
@dschrempf is right: Nix 2.15 should be creating gcroots in |
Yes.
I ran this command as root, nothing changed, the broken links remained. |
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 ~ 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 ~ 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. |
Hm, interesting. I can confirm that a broken link in I also observe that However, since I only use EDIT: I checked once more, and broken links pointing from
It seems like I do not know well enough how garbage collection works :-)! |
I could be wrong - but this looks to be the same bug that @dschrempf opened upstream to me? |
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 bynix-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!
The text was updated successfully, but these errors were encountered: