-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Direnv sets a terminfo
variable to a string, when in zsh it's an array
#405
Comments
I keep coming back to this, trying to respond, and then closing the tab because there's just a lot going on and formulating a response is frankly a bit difficult. I think the reason for this is that it is unclear where to start debugging. Are you sure you had nix-direnv loaded? (direnv includes a non-caching To clarify your point about direnv loading async: It does not. direnv kicks in when your prompt is going to be generated. It launches a subshell wherein it runs your looking at your flakes: I would expect I might suggest checking on the profile rc that is created during nix-direnv's evaluation (and which is the thing we use for caching). Maybe see if the profile_rc's created by the two flakes are equivalent or if the |
ping? I don't want to close this without addressing it, but without feedback I don't know that we can do much? |
Sorry, I went with copying the entire |
Goddamit, I only now understood the actual issue: zsh doesn't like when a package has Late edit: it's actually resolved, adding |
Okay - I don't really think this is nix-direnv's problem, as we faithfully recreated the environment we were handed. But I also do not like leaving it as "well, just unset problematic variables". @Mic92 Do you have ideas on how we might blacklist some variables for some host shells? I don't think we can rely on For anyone else watching: We had a short discussion on matrix about this and I asked about the feasibility of adding a |
We do filter some environment variables out: Line 156 in a59f38b
Question is, is terminfo worth it being treated special? I would expect very few derivations would try to export this. The work-around is adding unset terminfo to either shellHook or .envrc.
|
I think we can achieve this simply? diff --git a/direnvrc b/direnvrc
index 50a84cf..24a7efb 100644
--- a/direnvrc
+++ b/direnvrc
@@ -137,6 +137,7 @@ _nix_import_env() {
local old_temp=${TEMP:-__UNSET__}
local old_tempdir=${TEMPDIR:-__UNSET__}
local old_xdg_data_dirs=${XDG_DATA_DIRS:-}
+ local old_terminfo=${terminfo:-__UNSET__}
# On the first run in manual mode, the profile_rc does not exist.
if [[ ! -e $profile_rc ]]; then
@@ -158,6 +159,7 @@ _nix_import_env() {
_nix_export_or_unset TMPDIR "$old_tmpdir"
_nix_export_or_unset TEMP "$old_temp"
_nix_export_or_unset TEMPDIR "$old_tempdir"
+ _nix_export_or_unset TERMINFO "$old_terminfo"
local new_xdg_data_dirs=${XDG_DATA_DIRS:-}
export XDG_DATA_DIRS=
local IFS=: But I might be a bit more aggressive here (bash introduced associative arrays in 4, so this is inline with our 4.4 minimum): diff --git a/direnvrc b/direnvrc
index 50a84cf..dbd97d1 100644
--- a/direnvrc
+++ b/direnvrc
@@ -131,12 +131,15 @@ _nix_export_or_unset() {
_nix_import_env() {
local profile_rc=$1
- local old_nix_build_top=${NIX_BUILD_TOP:-__UNSET__}
- local old_tmp=${TMP:-__UNSET__}
- local old_tmpdir=${TMPDIR:-__UNSET__}
- local old_temp=${TEMP:-__UNSET__}
- local old_tempdir=${TEMPDIR:-__UNSET__}
- local old_xdg_data_dirs=${XDG_DATA_DIRS:-}
+ local -A values_to_restore=(
+ ["NIX_BUILD_TOP"]=${NIX_BUILD_TOP:-__UNSET__},\
+ ["tmp"]=${TMP:__UNSET__},\
+ ["TMPDIR"]=${TMPDIR:-__UNSET__},\
+ ["TEMP"]=${TEMP:-__UNSET__},\
+ ["TEMPDIR"]=${TEMPDIR:-__UNSET__},\
+ ["terminfo"]=${terminfo:-__UNSET__}
+ )
+ local old_xdg_data_dirs=${"XDG_DATA_DIRS":-}
# On the first run in manual mode, the profile_rc does not exist.
if [[ ! -e $profile_rc ]]; then
@@ -153,11 +156,10 @@ _nix_import_env() {
rm -rf "$NIX_BUILD_TOP"
fi
- _nix_export_or_unset NIX_BUILD_TOP "$old_nix_build_top"
- _nix_export_or_unset TMP "$old_tmp"
- _nix_export_or_unset TMPDIR "$old_tmpdir"
- _nix_export_or_unset TEMP "$old_temp"
- _nix_export_or_unset TEMPDIR "$old_tempdir"
+ for key in ${!values_to_restore[@]}; do
+ _nix_export_or_unset "$key" "${values_to_restore[${key}]}"
+ done
+
local new_xdg_data_dirs=${XDG_DATA_DIRS:-}
export XDG_DATA_DIRS=
local IFS=: |
Yeah. now that we allow bash4 we can use associative arrays. |
I'll get a PR open soon for this. I have the work done already locally. |
@acid-bong: Could you please give this a test with latest master? Should be resolved now. :) |
Can confirm, it does work now as expected |
terminfo
variable to a string, when in zsh it's an array
I've created a flake for my build of
st
terminal, and originally it was overriding some attributes of nixpkgs' derivation. In that case direnv (withuse flake
in.envrc
) didn't load the environment consistently:make
,pkg-config
and/orgcc
CC=gcc
)impure
, no text or kept the name of different flakes I maintain (Icd
in and out my flakes), and sometimes it kept the wordimpure
when I exited the troublesome flake dirIt was also noticeable that it tried to run the
preInstall
command defined by nixpkgs' derivation ofst
, andTERMINFO
variable didn't go well with Zsh (I assume Direnv loads asynchronously) -- it produced(eval):export:1: terminfo: inconsistent type for assignment
(although tried setting it manually, works normally). Retried entering and exiting in Bash, no such issue appears.I rewrote the flake from
overrideAttrs
and basically copypasted the build recipe from nixpkgs, now Direnv loads the environment consistently, doesn't run thatexport
command.This also didn't happen in other flakes, like dwm (also
overrideAttrs
-based) and manually patched Victor Mono (mkDerivation
-based).The text was updated successfully, but these errors were encountered: