xzfc / cached-nix-shell

Instant startup time for nix-shell
https://xzfc.github.io/cached-nix-shell/cached-nix-shell.1
The Unlicense
195 stars 16 forks source link

'unbound variable' when variable is set in a shell-hook #15

Closed expipiplus1 closed 4 years ago

expipiplus1 commented 4 years ago

When entering a shell with a package which sets an env variable in a shell hook cached nix shell fails with the error 'unbound variable'

To reproduce:

$ cached-nix-shell -p vulkan-validation-layers
cached-nix-shell: updating cache
/nix/store/23qgk9g5bcsjf5bq0akcs76iw7b533f7-vulkan-validation-layers-1.2.131.2/nix-support/setup-hook: line 1: XDG_DATA_DIRS: unbound variable
cached-nix-shell: nix-shell: exit code: 1
expipiplus1 commented 4 years ago

Well, I suppose bash fails with this message technically

xzfc commented 4 years ago

In this particular case, the error is caused by a setupHook that tries to read an impure variable. It reproducible by nix-shell --pure -p vulkan-validation-layers.

xzfc commented 4 years ago

This particular case could be handled by passing --keep explicitly (added in 0e73944dc31132d2aa9a769f4cc677eea6984bec): cached-nix-shell --keep XDG_DATA_DIRS -p vulkan-validation-layers

expipiplus1 commented 4 years ago

Ah, I didn't know about keep!

Thanks again for the useful tool!

xzfc commented 4 years ago

Ah, I didn't know about keep!

I added it just now. 😅

expipiplus1 commented 4 years ago

Thanks! Using it already :)

On Sat, Apr 18, 2020 at 7:05 PM xzfc notifications@github.com wrote:

Ah, I didn't know about keep!

I added it just now. 😅

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/xzfc/cached-nix-shell/issues/15#issuecomment-615842323, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGRJXEDQOYSRHTPJHCNJN3RNGCOHANCNFSM4MLIQ54Q .