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

devenv removes itself during garbage collection #1429

Open
DriesCruyskens opened this issue Sep 8, 2024 · 9 comments
Open

devenv removes itself during garbage collection #1429

DriesCruyskens opened this issue Sep 8, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@DriesCruyskens
Copy link

Describe the bug
After running devenv gc in a project that has been initialised by devenv. The devenv command is not available anymore and has to be reinstalled.

To reproduce

$ devenv gc
✔ Removing non-existing symlinks in /Users/driescruyskens/.local/share/devenv/gc ... in 0.0s.
• Found 13 active environments.
• Deleted 36 dangling environments (most likely due to previous GC).
warning: Your daemon version is too old to support garbage collecting a closure, falling back to a full gc
✔ Running garbage collection (this process may take some time) ... in 6.4s.

• Done. Successfully removed 2 symlinks in 6.3727255s.
$ devenv shell
zsh: command not found: devenv

This happens even in a freshly initialised devenv project.

Version

devenv 1.0.8 (aarch64-darwin)

@DriesCruyskens DriesCruyskens added the bug Something isn't working label Sep 8, 2024
@sandydoo
Copy link
Member

sandydoo commented Sep 8, 2024

How is (or was) devenv installed on this machine?

@DriesCruyskens
Copy link
Author

Using the following commands:

$ sh <(curl -L https://nixos.org/nix/install)
$ nix-env -iA devenv -f https://github.com/NixOS/nixpkgs/tarball/nixpkgs-unstable

@sandydoo
Copy link
Member

sandydoo commented Sep 8, 2024

Strange! nix-env installs things to a profile (~/.nix-profile), which should be protected from garbage collection.

A couple of things to check:

  1. nix-env -q. Is devenv still listed? Is devenv available if you open a new shell?
  2. What if we take devenv out of the equation and just run nix-store --gc or nix store gc? Does that also delete devenv?

@DriesCruyskens
Copy link
Author

  • nix-env -q does not list devenv. devenv is not available when opening new shell.
  • nix-store --gc also removes devenv

When I follow all the symlinks of my nix profile. /Users/driescruyskens/.nix-profile -> /Users/driescruyskens/.local/state/nix/profiles/profile -> profile-1-link -> /nix/store/y9hqy0x0rrdhsz2qkfmyrw6l62lgxhvw-user-environment. Notice this last one is removed during gc:

$ nix-store --gc
finding garbage collector roots...
deleting garbage...
deleting '/nix/store/y9hqy0x0rrdhsz2qkfmyrw6l62lgxhvw-user-environment' # <- should this be removed in gc?
deleting '/nix/store/xp5636bdvww7nbcmj9ymrghg6b9skm67-devenv-1.0.8.drv'
deleting '/nix/store/d8z3qwsk69ccqwi5b7wkn27qmkj59vb6-cachix-1.7.4.drv'
deleting '/nix/store/xp6jr77acv1n1y0iadbhm52frarpzw76-dhall-1.42.1.drv'
deleting '/nix/store/szd5h9bnrhxf34p4dxj4f24nwlz7wjwf-cachix-api-1.7.4.drv'
deleting '/nix/store/yqa3dx4jrnapwms6chvd88k3ppwhxcni-swagger2-2.8.9.drv'
deleting '/nix/store/bzc0i86k11ydpclgqcnzcq60y5fag3cw-user-environment.drv'
deleting '/nix/store/m9fb339s5l3631k6mnc52j15lmy42y9y-env-manifest.nix'
deleting '/nix/store/j8qgrzwxaxikw111n0iqbc473jvg9ggc-devenv-1.0.8'
deleting '/nix/store/90rq091pmn9ijrqgablkk0gzvhxi98xh-cachix-1.7.4-bin'
deleting '/nix/store/79yns69mv7y53a3qjl20a2mf6c6128rf-servant-conduit-0.16.drv'
deleting '/nix/store/spr6bawk3gzbpp4cqd3kbdx568qy52n4-servant-client-0.20.drv'
deleting '/nix/store/rg4yx0rnvxji1dspmhqss55ln9bwv240-servant-server-0.20.drv'
deleting '/nix/store/lnaawr42l8ix04m62cd50y8ycirc11ka-wai-app-static-3.1.9.drv'
deleting '/nix/store/dr9gccblgfflaqghpjnrzfvq81r7v7pa-hspec-wai-0.11.1.drv'
deleting '/nix/store/sgyyj2g62ndpk6nrh061v5b714l3j1n8-wai-extra-3.1.15.drv'
deleting '/nix/store/2d8vgsy0qc50bw4zdv5p9qld0w7i5gy1-warp-3.3.31.drv'
deleting '/nix/store/qlz4xkkw15zy02hjldqpyqfqa4fcx9zq-http2-5.0.1.drv'
deleting '/nix/store/1yn3crf6cdwmq2yn3046fx0w668rv24g-cborg-json-0.2.6.0.drv'
...

@sandydoo
Copy link
Member

sandydoo commented Sep 8, 2024

So, we've narrowed it down to an issue with Nix. No, the user-environment should not be deleted in this case. That profile link should be a GC root, preventing it from being GC'd.

nix-store -q --roots /nix/store/y9hqy0x0rrdhsz2qkfmyrw6l62lgxhvw-user-environment

Normally, this query should return something like /Users/driescruyskens/.local/state/nix/profiles/profile/profile-1-link -> /nix/store/y9hqy0x0rrdhsz2qkfmyrw6l62lgxhvw-user-environment, confirming that the path is protected from GC. I'm not sure what has gone wrong here.

@sandydoo
Copy link
Member

sandydoo commented Sep 8, 2024

Assuming it's an installation issue, you could give the alternate installer (or the detsys one from which it's forked) a try. These are far better on all fronts, and particularly so for macOS.

I won't have the internet bandwidth to try to replicate this in a fresh VM for at least the next week. IPSWs are large. But it would be good to figure out what went wrong here 🤔

@DriesCruyskens
Copy link
Author

Running nix-store -q --roots /nix/store/y9hqy0x0rrdhsz2qkfmyrw6l62lgxhvw-user-environment returned an empty document. I was indeed able to fix the issue by uninstalling and using detsys installer. Thanks for your time on this great project!

@MalteMagnussen
Copy link

Maybe not related, but what does this mean: warning: Your daemon version is too old to support garbage collecting a closure, falling back to a full gc

Full:

mhm@mhm:~/Documents/asset-search/search$ devenv gc
✔ Removing non-existing symlinks in /home/mhm/.local/share/devenv/gc ... in 0.0s.
• Found 62 active environments.
• Deleted 0 dangling environments (most likely due to previous GC).
warning: Your daemon version is too old to support garbage collecting a closure, falling back to a full gc

I'd have liked to open a discussion on this, but unless I'm blind, this repository does not have discussions.

My shell was not deleted during the gc btw. Only took 11.5s to enter it again. Whereas a fresh shell took minutes to build.

@sandydoo
Copy link
Member

what does this mean: warning: Your daemon version is too old to support garbage collecting a closure, falling back to a full gc

@MalteMagnussen, this has been fixed in v1.1.

It's an innocuous message that Nix is doing a GC run of the entire store, instead of checking just the shell environments we've asked it to check. In other words, this translates to "hang on, this is going to take a while".
AFAIK, you'd always see this message because the closure GC patches weren't quite layered correctly.

I'd have liked to open a discussion on this, but unless I'm blind, this repository does not have discussions.

We have a pretty active Discord for these things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants