cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.52k stars 339 forks source link

Cannot run `devenv gc` #1145

Open p16i opened 7 months ago

p16i commented 7 months ago

Describe the bug I have just moved to nixOS, and I am learning how to use devenv for my development environments. It seems that the devenv gc due to an error of unexpected argument for the command nix store gc.

To reproduce

In this case, the devenv.nix and devenv.yaml that I have are directly from what devenv init provides.

Error when running devenv gc

$ devenv -v  gc
✔ Removing non-existing symlinks in /home/pat/.local/share/devenv/gc ... in 0.0s.
• Found 10 active environments.
• Deleted 5 dangling environments (most likely due to previous GC).
• Running garbage collection (this process may take some time) ... ...• Running command: nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty false --option eval-cache false --keep-going --max-jobs 4 store gc /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env /nix/store/zkx25311cyffvbpl8jvb1aiikd58crnh-devenv-shell-env /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env
error:
       error: unexpected argument '/nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env'

Version

devenv 1.0.4 
nix (Nix) 2.18.1
sbocinec commented 7 months ago

I'm experiencing siimilar error with devenv gc and devenv 1.0.4 caused by the unknown impure argument:

cloudv on  main [$!?] via 🐹 v1.22.1 via  v18.12.1 with 🐃 v1.30.0 via ❄️  impure (devenv-shell-env) on ☁️ 
❯ devenv gc
✔ Removing non-existing symlinks in /home/stano/.local/share/devenv/gc ... in 0.0s.
• Found 9 active environments.
• Deleted 0 dangling environments (most likely due to previous GC).
error:
       error: unexpected argument '/nix/store/7fpp142mg3ccryxakwpz5q2pyf4yhf5h-devenv-shell-env'
Try '/nix/store/a0i9g29xgmk42gjjglzd6k0kzyjkay3n-nix-2.21-devenv/bin/nix --help' for more information.

✖ Command produced the following output:

✔ Running garbage collection (this process may take some time) ... in 0.0s.
Error:   × Command `/nix/store/a0i9g29xgmk42gjjglzd6k0kzyjkay3n-nix-2.21-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty false --option eval-cache false --keep-
  │ going --max-jobs 6 store gc /nix/store/7fpp142mg3ccryxakwpz5q2pyf4yhf5h-devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/
  │ r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/qjns4077lyh4626xa14ps875krjdb7fn-devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-
  │ env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env --impure` failed with with exit code 1

This is my devenv.yaml:

allowUnfree: true
impure: true
inputs:
  nixpkgs:
    url: github:NixOS/nixpkgs/nixpkgs-unstable
  nixpkgs-terraform:
    url: github:stackbuilders/nixpkgs-terraform
domenkozar commented 7 months ago

@p16i does /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env exist?

p16i commented 7 months ago

@domenkozar thanks for promptly response!

This is what I got

$ ls -la  /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env
-r--r--r-- 1 root root 71596 Jan  1  1970 /nix/store/wymhs667k4ggiaz7lq1vcycsi97vkmwf-devenv-shell-env

It is there but empty.

sbocinec commented 7 months ago

@domenkozar thanks for working on the issue :raised_hands:

Btw is there a way how to run gc manually? I've tried to remove impure: true from my devenv.yaml, but it's still failing and I've already ran out of the disk space, completely blocked from using devenv rn.

$ devenv gc                                                       
✔ Removing non-existing symlinks in /home/stano/.local/share/devenv/gc ... in 0.0s.
• Found 14 active environments.
• Deleted 0 dangling environments (most likely due to previous GC).
error:
       error: unexpected argument '/nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env'
Try '/nix/store/a0i9g29xgmk42gjjglzd6k0kzyjkay3n-nix-2.21-devenv/bin/nix --help' for more information.

✖ Command produced the following output:

✔ Running garbage collection (this process may take some time) ... in 0.0s.
Error:   × Command `/nix/store/a0i9g29xgmk42gjjglzd6k0kzyjkay3n-nix-2.21-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features
  │ flakes --option warn-dirty false --option eval-cache false --keep-going --max-jobs 6 store gc /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/
  │ store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/7fpp142mg3ccryxakwpz5q2pyf4yhf5h-devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-
  │ devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/
  │ r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/qjns4077lyh4626xa14ps875krjdb7fn-devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-
  │ devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/
  │ r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-shell-env /nix/store/r3d57ii1jb27crfm7mxcww42v8jsw2mb-devenv-
  │ shell-env` failed with with exit code 1
domenkozar commented 7 months ago

sudo -E nix-collect-garbage

sbocinec commented 7 months ago

sudo -E nix-collect-garbage

Awesome, TY!

One OT note for others: the command didn't work with -E ( I have devenv & nix installed on Ubuntu 22.04):

$ sudo -E nix-collect-garbage
sudo: nix-collect-garbage: command not found

Though switching to root without preserving the env vars (sudo -i) and executing nix-collect-garbage worked:

stano@rpu ~/workspace/redpanda/cloudv2/apps/external-dns-helper (main*?) $ sudo -i
root@rpu:~# which nix-collect-garbage 
/root/.nix-profile/bin/nix-collect-garbage
root@rpu:~# 
logout

$ which nix-collect-garbage
/nix/var/nix/profiles/default/bin/nix-collect-garbage
domenkozar commented 7 months ago

This is a bug in this PR: https://github.com/NixOS/nix/pull/8417