Fix parsing of direnv export json to support unset of environment variables + better logging (#32559)

Release Notes:

- Fixed parsing of `direnv export json` output to support unset of
environment variables.
This commit is contained in:
Michael Sloan 2025-06-11 11:57:30 -06:00 committed by GitHub
parent 65a1d09d24
commit 027ce6889c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 12 deletions

View file

@ -274,7 +274,13 @@ async fn load_shell_environment(
},
};
if let Some(direnv_environment) = direnv_environment {
envs.extend(direnv_environment);
for (key, value) in direnv_environment {
if let Some(value) = value {
envs.insert(key, value);
} else {
envs.remove(&key);
}
}
}
(Some(envs), direnv_error)