devenv
devenv copied to clipboard
`devenv update` doesn't update
Describe the bug
devenv update doesn't update the lockfile.
To reproduce
Here's a gist with all the files. The config was entirely generated by devenv init, except it's wrong by default[^1], so I added unset P1 per the official advice (see the very bottom of the wiki page) to avoid errors when loading the env. The .gitignore is larger, as devenv init was run in an existing project.
Upon enabling the devenv via direnv, devenv complains that the lockfile should be updated.
$ cd -
/home/xr587/projects/foo
direnv: loading ~/projects/foo/.envrc
direnv: loading https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc (sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0=)
direnv: using devenv
direnv: using cached devenv shell
✨ devenv 1.0.8 is newer than devenv input in devenv.lock. Run `devenv update` to sync.
hello from devenv
git version 2.44.0
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +DEVENV_DOTFILE +DEVENV_PROFILE +DEVENV_ROOT +DEVENV_RUNTIME +DEVENV_STATE +GREET +IN_NIX_SHELL +LD +LOCALE_ARCHIVE +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_LDFLAGS +NIX_PKG_CONFIG_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_STORE +NM +OBJCOPY +OBJDUMP +PKG_CONFIG +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +cmakeFlags +configureFlags +mesonFlags +name +system -BASH_COMMAND ~LINENO ~PATH ~XDG_DATA_DIRS
However, running devenv update doesn't change the lockfile. Subsequent env loads show the same ✨ devenv 1.0.8 is newer than devenv input message.
By the way, devenv update seems to ignore errors altogether. Try e.g. getting rate-limited by GitHub with enough devenv update calls:
devenv update proceeds as if no errors were encountered and exits with a zero exit code.
Version
devenv 1.0.8 (x86_64-linux)
[^1]: The config generated by devenv init has direnv errors with $PS1.
@k3yss can you take a look?
@viluon I can't reproduce devenv update not updating to the 1.0.8 version, this is the command I am running:
~/sandbox/cachix/issues/devenv-update (master) » devenv update k3ys@nixos
• Updating devenv.lock .
• Updated input 'devenv':
'github:cachix/devenv/44bfc26843694ab17ebae1d4922065e48d93f501?dir=src/modules' (2024-07-24)
→ 'github:cachix/devenv/075c114280751f956335333179304d14ae01aedc?dir=src/modules' (2024-07-26)
• Updated input 'pre-commit-hooks/nixpkgs-stable':
'github:NixOS/nixpkgs/a1cc729dcbc31d9b0d11d86dc7436163548a9665' (2024-07-25)
→ 'github:NixOS/nixpkgs/8c50662509100d53229d4be607f1a3a31157fa12' (2024-07-27)
✔ Updating devenv.lock in 0.5s.
direnv: loading ~/sandbox/cachix/issues/devenv-update/.envrc
direnv: loading https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc (sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0=)
direnv: using devenv
direnv: .envrc changed, reloading
direnv: updated devenv shell cache
hello from devenv
git version 2.44.0
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +DEVENV_DOTFILE +DEVENV_PROFILE +DEVENV_ROOT +DEVENV_RUNTIME +DEVENV_STATE +GREET +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_LDFLAGS +NIX_PKG_CONFIG_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_STORE +NM +OBJCOPY +OBJDUMP +PKG_CONFIG +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +cmakeFlags +configureFlags +mesonFlags +name +system ~PATH ~XDG_DATA_DIRS
--------------------------
With the diff being:
diff --git a/devenv.lock b/devenv.lock
index 0803202..12a424b 100644
--- a/devenv.lock
+++ b/devenv.lock
@@ -3,11 +3,11 @@
"devenv": {
"locked": {
"dir": "src/modules",
- "lastModified": 1721817837,
+ "lastModified": 1722019186,
"owner": "cachix",
"repo": "devenv",
- "rev": "44bfc26843694ab17ebae1d4922065e48d93f501",
- "treeHash": "62b4ad814fcc952c5660916c9cdadc34927b3330",
+ "rev": "075c114280751f956335333179304d14ae01aedc",
+ "treeHash": "0e550d934a0d3f6248accff4c019c013e8e237e6",
"type": "github"
},
"original": {
@@ -72,11 +72,11 @@
},
"nixpkgs-stable": {
"locked": {
- "lastModified": 1721949857,
+ "lastModified": 1722087241,
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "a1cc729dcbc31d9b0d11d86dc7436163548a9665",
- "treeHash": "39c0cfae49b35d4880cf1c2570fa51d22b7e4719",
+ "rev": "8c50662509100d53229d4be607f1a3a31157fa12",
+ "treeHash": "cbc560aaf05dfc49bde55e55f603d7245515b13a",
"type": "github"
},
"original": {
If possible, can you provide another example that is more easily reproducible? I think the issue may be related to the .direnv or .devenv directory being present. If you can upload the entire project somewhere, it might be more reproducible that way.
I can successfully reproduce the GitHub rate limit bug, and I will look into it.
@k3yss as luck would have it, my own subsequent attempts to reproduce the first issue also failed, which is lavishly weird. I should have backed up the entire project with the failing update. After removing devenv/direnv files from it and running devenv init again I could not reproduce the original problem.
That's not to say devenv init is without its issues, it certainly creates the wrong direnv config by default:
devenv-repro on main
❯ git status
On branch main
No commits yet
nothing to commit (create/copy files and use "git add" to track)
devenv-repro on main
❯ devenv init
• Creating devenv.nix
• Creating devenv.yaml
• Creating .envrc
• Creating .gitignore
direnv: loading /tmp/devenv-repro/.envrc
direnv: loading https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc (sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0=)
direnv: using devenv
direnv: .envrc changed, reloading
• Using Cachix: devenv
✖ You're not a trusted user of the Nix store. You have the following options:
a) Add yourself to the trusted-users list in /etc/nix/nix.conf for devenv to manage caches for you.
trusted-users = root unknown
Restart nix-daemon with:
$ sudo systemctl restart nix-daemon
b) Add binary caches to /etc/nix/nix.conf yourself:
extra-substituters = https://devenv.cachix.org
extra-trusted-public-keys = devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=
And disable automatic cache configuration in `devenv.nix`:
{
cachix.enable = false;
}
• Failed to get cachix caches due to evaluation error
direnv: updated devenv shell cache
hello from devenv
git version 2.44.0
direnv: PS1 cannot be exported. For more information see https://github.com/direnv/direnv/wiki/PS1
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +DEVENV_DOTFILE +DEVENV_PROFILE +DEVENV_ROOT +DEVENV_RUNTIME +DEVENV_STATE +GREET +IN_NIX_SHELL +LD +LOCALE_ARCHIVE +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_LDFLAGS +NIX_PKG_CONFIG_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_STORE +NM +OBJCOPY +OBJDUMP +PKG_CONFIG +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +cmakeFlags +configureFlags +mesonFlags +name +system -BASH_COMMAND ~LINENO ~PATH ~XDG_DATA_DIRS
devenv-repro on main [?]
❯
Thank you for looking into the rate limit bug. If the error handling of devenv update is suspect, perhaps the rate limit thing and the fail to update the lockfile share a root cause.
@viluon
direnv: PS1 cannot be exported. For more information see https://github.com/direnv/direnv/wiki/PS1
This issue is mostly related to how direnv handles your terminal prompt. For my terminal config I see no such errors and I think if you use a more simpler prompt you won't have to edit the .envrc at all. Here is what happens when I do a devenv init
~/sandbox/cachix/issues/init » devenv init k3ys@nixos
• Creating devenv.nix
• Creating devenv.yaml
• Creating .envrc
• Creating .gitignore
direnv: loading ~/sandbox/cachix/issues/init/.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.
• Using Cachix: devenv
direnv: updated devenv shell cache
hello from devenv
git version 2.44.0
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +DEVENV_DOTFILE +DEVENV_PROFILE +DEVENV_ROOT +DEVENV_RUNTIME +DEVENV_STATE +GREET +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_LDFLAGS +NIX_PKG_CONFIG_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_STORE +NM +OBJCOPY +OBJDUMP +PKG_CONFIG +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +cmakeFlags +configureFlags +mesonFlags +name +system ~PATH ~XDG_DATA_DIRS
~/sandbox/cachix/issues/init »
This looks like it was GitHub rate limiting.