devenv: Devenv hangs forever
Describe the bug Hello! I have a problem with Devenv on MacOS (Sonoma 14.6). When I try to init devenv it hangs at the devenv init step:
devenv init
• Creating devenv.nix
• Creating devenv.yaml
• Creating .envrc
• Creating .gitignore
direnv: loading ~/ops-stuff/repos/github-management/.envrc
direnv: loading https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc (sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0=)
direnv: using devenv
direnv: .envrc changed, reloading
direnv: ([direnv export zsh]) is taking a while to execute. Use CTRL-C to give up.||
It hangs forever if you don’t press Ctrl-C. I checked what it runs underneath the hood via ps and ran the same command with an extra verbose.
/nix/store/z1zrijdcxzx5a8yf4prggamg6k41hcmi-nix-2.21-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty false --keep-going --max-jobs 4 --option eval-cache false eval .#devenv.cachix --json -vvvvvvvv
evaluating file '<nix/derivation-internal.nix>'
using cache entry '{"_what":"gitLastModified","rev":"0a41d25e85caeb81211a5742b47a9a986edf35d2"}' -> '{"lastModified":1722604605}'
evaluating file '/.devenv.flake.nix'
And it stuck on the evaluating file /.devenv.flake.nix.
The same thing happens if I’m trying to run any command.
For example if I run devenv info:
devenv info -v
• Running command: /nix/store/z1zrijdcxzx5a8yf4prggamg6k41hcmi-nix-2.21-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty false --keep-going --max-jobs 4 --option eval-cache false flake metadata
• Running command: /nix/store/z1zrijdcxzx5a8yf4prggamg6k41hcmi-nix-2.21-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty false --keep-going --max-jobs 4 --option eval-cache false eval --raw .#info
And it hangs forever. Same thing if I run the command manually:
/nix/store/z1zrijdcxzx5a8yf4prggamg6k41hcmi-nix-2.21-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty false --keep-going --max-jobs 4 --option eval-cache false eval --raw .#info -vvvvvvvvvvv
evaluating file '<nix/derivation-internal.nix>'
using cache entry '{"_what":"gitLastModified","rev":"030722876accf9f65d17616d6d435f982c0ceb2f"}' -> '{"lastModified":1722513473}'
evaluating file '/.devenv.flake.nix'
I tried re-install nix and devenv but it didn’t help.
To reproduce
devenv init
Examples are above.
Version OS: MacOS Sonoma (14.6)
devenv version
devenv 1.0.8 (aarch64-darwin)
Nix version: 2.24.1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 23
- Comments: 34 (6 by maintainers)
Commits related to this issue
- nix: core: set usable Nix version `latest` makes "devenv" hang forever for some reason, see https://github.com/cachix/devenv/issues/1364 for details, while more dated versions either lack essential f... — committed to wiedzmin/nixos-config by wiedzmin 2 years ago
- nix: core: set usable Nix version `latest` makes "devenv" hang forever for some reason, see https://github.com/cachix/devenv/issues/1364 for details, while more dated versions either lack essential f... — committed to wiedzmin/nixos-config by wiedzmin 2 years ago
- nix: core: set usable Nix version `latest` makes "devenv" hang forever for some reason, see https://github.com/cachix/devenv/issues/1364 for details, while more dated versions either lack essential f... — committed to wiedzmin/nixos-config by wiedzmin 2 years ago
It seems there’s a problem with the latest versions of Nix. I’ve completely uninstalled Nix And installed the older 2.21.4 version via:
sh <(curl -L https://releases.nixos.org/nix/nix-2.21.4/install)And it doesn’t hang now and seems to be working.OK I have figured out what the problem is: for some reason the nix-devenv Nix is reporting protocol 38, which it absolutely is not compliant with, which is then causing protocol negotiation to explode. Either this is a poorly thought out patch in devenv-nix, or a failure on the part of CppNix to increment protocol versions when they make protocol changes.
I am going to go look at the devenv-nix patches and we are going to find out which one it is.
Consider the client side:
And the server side:
Going to look into this today/tomorrow. Thanks a lot @lf-
Can confirm the same as above (w.r.t. versions) on a pretty vanilla Ubuntu 24.04.
Some additional info:
roothas no issue usingdevenvon the exact same multi-user nix installation whereas it fails for non-previleged users;readin the libc6 bundled by Nix.As @rfhayashi mentioned (thanks!), downgrading Nix to 2.23.3 fixes everything.
Silly me! I didn’t even realise I could do that!
Just in-case anyone else wasn’t aware either 👍🏻
I’ve also managed to reproduce the issue in nix
2.24.0and2.24.1in Linux (Debian). It worked using2.23.3. This only happens using the multi-user installation, the single-user works ok.Still broken for me (darwin)
Actually nevermind. The first init just took a very long time.
Yeap, you have to uninstall (https://nix.dev/manual/nix/2.24/installation/uninstall) and install again using
sh <(curl -L https://releases.nixos.org/nix/nix-2.23.3/install) --daemonThe workaround is to downgrade Nix to 2.23.3
Running as root is expected to not get this problem because it’s not using the nix protocol, it scribbles over the store without using the daemon.
Ok so here’s the part where you kind of cry: I would advise getting debug info from both the nix client and the nix daemon, then gdb both of them and run them in lock step. Nix protocol desyncs are a nightmare.
it’s happening with me too
Can confirm it has been fixed. Thanks @domenkozar !!
This is a broken patch to devenv-nix: https://github.com/domenkozar/nix/commit/537b7de306a52ed4b35799cfc180e3aa39d0e07a is not safe to pick without the other protocol changes made prior to it, which seem to be missing as observed above (the client should be sending client features).
It doesn’t work, sadly:
Seems like they have fixed this, hopefully: https://github.com/NixOS/nix/issues/11258