lorri icon indicating copy to clipboard operation
lorri copied to clipboard

darwin flake: reloads .envrc on every shell command

Open ulzu opened this issue 11 months ago • 4 comments

Describe the bug

reloads .envrc, printing direnv: loading <cd>/.envrc and direnv: export +..., on every shell command. if lorri daemon is enabled, cd inside the flake directory reloads it twice.

To Reproduce

  1. enter flake directory
  2. run any shell command

Expected behavior

.envrc is loaded once, upon entering flake directory.

Metadata

$ lorri info
Project Shell File: /Users/lukas/labs/zig/flake.nix
Project Garbage Collector Root: /Users/lukas/Library/Caches/com.github.nix-community.lorri.lorri.lorri/gc_roots/0238430c2a5762a8b2777bdf01e7692d/gc_root/shell_gc_root

General:
Lorri User GC Root Dir: /Users/lukas/Library/Caches/com.github.nix-community.lorri.lorri.lorri/gc_roots
Lorri Daemon Socket: /Users/lukas/Library/Caches/com.github.nix-community.lorri.lorri.lorri/daemon.socket
Lorri Daemon Status: `lorri daemon` is not up: Unable to connect to socket at /Users/lukas/Library/Caches/com.github.nix-community.lorri.lorri.lorri/daemon.socket, is the daemon running?

$ uname -a
Darwin Lukass-MBP.lan 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 arm64 arm Darwin

Additional context

Daemon doesn't print anything of interest. Environment built using this hack, but issue persists when loading cached version with the hack disabled. Does not reload .envrc on shell.nix variant. Tested with zsh and bash, configless.

ulzu avatar Jan 16 '25 19:01 ulzu

Could you share your flake.nix file? I don't have easy access to a Darwin environment, but maybe I can help debug. You might also capture the output of lorri internal steam-events - it might indicate which files are triggering a rebuild

nyarly avatar Jan 16 '25 20:01 nyarly

I reduced it to a minimal setup of a flake with a single devShell without any packages and an otherwise empty directory. lorri internal stream-events prints nothing of interest:

{"Started":{"nix_file":"/Users/lukas/labs/nix/lorri-minimal/flake.nix","reason":{"FilesChanged":["/Users/lukas/labs/nix/lorri-minimal/flake.nix","/Users/lukas/labs/nix/lorri-minimal/flake.nix"]}}}
{"Completed":{"nix_file":"/Users/lukas/labs/nix/lorri-minimal/flake.nix","rooted_output_paths":{"shell_gc_root":"/Users/lukas/Library/Caches/com.github.nix-community.lorri.lorri.lorri/gc_roots/0bf43fd2018b3fe1a27aecd19b4ce53c/gc_root/shell_gc_root"}}}

It's not rebuilding - it's reevaluating .envrc and reloading the (cached) environment.

(bash and zsh come from nixpkgs-master, not the old versions of macos.)

ulzu avatar Jan 17 '25 10:01 ulzu

Interesting. Does direnv report what changed? I think there's ways to get it to. Sorry, I'm in the weird position of having time on my hands but not having my workstation available, so advice is a little vague.

If it's lorri's output, getting successive versions and comparing would be informative

nyarly avatar Jan 18 '25 17:01 nyarly

I added the Sponsoring solicited label, since issues on MacOS are a good candidate for sponsoring developer time.

Profpatsch avatar Feb 20 '25 21:02 Profpatsch