diff --git a/crates/nu-cli/src/env/directory_specific_environment.rs b/crates/nu-cli/src/env/directory_specific_environment.rs index 16a5dd605a..d2f6295bd2 100644 --- a/crates/nu-cli/src/env/directory_specific_environment.rs +++ b/crates/nu-cli/src/env/directory_specific_environment.rs @@ -1,7 +1,6 @@ use indexmap::IndexMap; use nu_protocol::{Primitive, UntaggedValue, Value}; -use std::io::Write; -use std::{ffi::OsString, fmt::Debug, fs::OpenOptions, path::PathBuf}; +use std::{ffi::OsString, fmt::Debug, path::PathBuf}; #[derive(Debug, Default)] pub struct DirectorySpecificEnvironment { diff --git a/crates/nu-cli/src/env/environment.rs b/crates/nu-cli/src/env/environment.rs index e5c88e4572..99e6f998be 100644 --- a/crates/nu-cli/src/env/environment.rs +++ b/crates/nu-cli/src/env/environment.rs @@ -71,17 +71,6 @@ impl Environment { Ok(()) } - fn remove_env(&mut self, key: &str) { - if let Some(Value { - value: UntaggedValue::Row(ref mut envs), - tag: _, - }) = self.environment_vars - { - envs.entries.remove(key); - std::env::remove_var(key); - }; - } - pub fn morph(&mut self, configuration: &T) { self.environment_vars = configuration.env(); self.path_vars = configuration.path(); diff --git a/crates/nu-cli/src/env/environment_syncer.rs b/crates/nu-cli/src/env/environment_syncer.rs index c4bf9bc525..177f32fb8e 100644 --- a/crates/nu-cli/src/env/environment_syncer.rs +++ b/crates/nu-cli/src/env/environment_syncer.rs @@ -44,11 +44,6 @@ impl EnvironmentSyncer { pub fn sync_env_vars(&mut self, ctx: &mut Context) { let mut environment = self.env.lock(); - // match environment.maintain_directory_environment() { - // Ok(_) => {} - // Err(e) => {panic!(e)} - // } - if environment.env().is_some() { for (name, value) in ctx.with_host(|host| host.vars()) { if name != "path" && name != "PATH" { @@ -57,22 +52,8 @@ impl EnvironmentSyncer { environment.add_env(&name, &value, false); environment - .direnv - .env_vars_to_add() - .unwrap() - .iter() - .for_each(|(k, v)| { - environment.add_env(&k, &v, true); - }); - - environment - .direnv - .overwritten_values_to_restore() - .unwrap() - .iter() - .for_each(|(k, v)| { - environment.add_env(&k, &v, true); - }); + .maintain_directory_environment() + .expect("Could not set directory-based environment variables"); // clear the env var from the session // we are about to replace them