direnv / direnv-vscode

unclutter your .profile
https://marketplace.visualstudio.com/items?itemName=mkhl.direnv
BSD Zero Clause License
169 stars 12 forks source link

addon messing with 44 variables with empty envrc #471

Open endigma opened 1 year ago

endigma commented 1 year ago

using fish shell + starship, addon causes integrated terminals to fail to load.

This only happens with this addon, not with direnv in general. Not sure how to debug this even

endigma commented 1 year ago

image This is in the addon logs, may have something to do with this?

endigma commented 1 year ago

image

The addon also reports +0/~44/-0, which is odd, as the .envrc is empty.

mkhl commented 1 year ago

FWIW it does work for me: image

You'll have to give me a lot more to be able to help. Maybe… tell me a bit about your system? How did you install the software and how are you running it? Where are fish and starship located? Does it matter where the workspace with the empty .envrc is? How reproducible is this behavior? I have no idea if I can help you but without more info I can't even start trying…

My 🔮 believes that nix is involved but I can't figure out how yet.

Also screenshots don't help without you describing why you included them, and are strictly worse than just posting the screenshotted text. Especially when the screenshots are severely cropped, like the extension output above. Which other environment variables were changed and how? Which internal direnv variables were changed?

endigma commented 1 year ago

Full extension output on failure: https://gist.github.com/endigma/7f135a9f002f33e0a1974b413acad068

mkhl commented 1 year ago

Thanks. Those variables are consistent with what a nix shell defines, the extension unsetting them all seems really weird…

You wouldn't happen to have installed vscode with nix, or started it from a nix-shell?

Does the direnv: Reset and reload environment change anything?

endigma commented 1 year ago

I'm currently working, and reproducing this requires reloading the window which breaks live share. I'll do any experimentation later.

No vscode nix, just normal systemwide nix afaik. I use any-nix-shell to make nix-shell work with fish when I do use it, which works completely fine outside of vscode with the addon enabled.

mkhl commented 1 year ago

There's no rush, I'm about to go to sleep anyways :)

endigma commented 1 year ago

This probably had something to do with having multiple direnv extensions installed. :sweat_smile:

endigma commented 1 year ago

Nevermind, just happened again. I was in some sort of limbo and reloaded and it's back.

No envrc in this folder, nor any parent. direnv status reports nothing, except that my bash path is in my nix store, which is abnormal.

Reset and reload does nothing.

direnv status
direnv exec path /usr/bin/direnv
DIRENV_CONFIG /home/end/.config/direnv
bash_path /nix/store/pk3kkaafln68gzxawk57qp9m5h5285va-bash-interactive-5.2-p15/bin/bash
disable_stdin false
warn_timeout 5s
whitelist.prefix [/home/end/repos/hussleinc/mesa]
whitelist.exact map[]
No .envrc or .env loaded
No .envrc or .env found
endigma commented 1 year ago

Adding

echo "Hello"

to .envrc seems to prevent the envar overwrite from happening, status bar now reads +0/~0/-0. There is a different issue now though, see following comment.

endigma commented 1 year ago

When it's "working", starship reports I'm in impure / nix-shell, but the only package seems to be nix-shell.

> nix-shell-info
nix-shell

> which bash
/nix/store/pk3kkaafln68gzxawk57qp9m5h5285va-bash-interactive-5.2-p15/bin/bash

> which ls
/nix/store/lyicmql3ws929d7azr65h25b2hyakmb6-coreutils-9.1/bin/ls

> which cargo # something a default nix-shell wouldn't provide
/home/end/.cargo/bin/cargo

This is consistent with behavior when running, for example, nix-shell -p bash, except that there's no shell.nix anywhere in the parent directories and use nix is not mentioned in the envrc.

endigma commented 1 year ago

If I use direnv block to block the almost-empty .envrc, the nix-shell goes away and I'm left with a stock environment.

direnv: error /tmp/tmp.inFuqoP3N6/.envrc is blocked. Run `direnv allow` to approve its content
> which bash
/usr/bin/bash
endigma commented 1 year ago

I think this error is caused by any-nix-shell. I use this with fish. Are you able to reproduce with this installed?

mkhl commented 1 year ago

Sorry, I haven't found the time to try and reproduce this with any-nix-shell yet, but I agree that it seems to be caused by it.

Could you try running without it? Nix started shipping with some fish integration in $HOME/.nix-profile/etc/profile.d/nix.fish at some point.

endigma commented 1 year ago

I've had it disabled for a while, don't really use nix-shell anymore so it hasn't been a huge issue. It would be good to have this fixed though. I recall having some other intermittent issues but none as consistently disruptive as the one that happens with any-nix-shell.