diff --git a/crates/nu-cli/src/env/environment.rs b/crates/nu-cli/src/env/environment.rs index 08479477b..9194580a0 100644 --- a/crates/nu-cli/src/env/environment.rs +++ b/crates/nu-cli/src/env/environment.rs @@ -40,26 +40,23 @@ pub struct Environment { impl Environment { pub fn new() -> Environment { - let mut e = Environment { + Environment { environment_vars: None, path_vars: None, - }; - e.add_nurc(); - e + } } pub fn from_config(configuration: &T) -> Environment { let env = configuration.env(); let path = configuration.path(); - let mut e = Environment { + Environment { environment_vars: env, path_vars: path, - }; - e.add_nurc(); - e + } } + //Add env vars specified in the current dirs .nurc, if it exists. pub fn add_nurc(&mut self) { let key = "envtest"; let value = "I am here!"; diff --git a/crates/nu-cli/src/env/environment_syncer.rs b/crates/nu-cli/src/env/environment_syncer.rs index 50f644cf2..f7315dee6 100644 --- a/crates/nu-cli/src/env/environment_syncer.rs +++ b/crates/nu-cli/src/env/environment_syncer.rs @@ -44,6 +44,7 @@ impl EnvironmentSyncer { pub fn sync_env_vars(&mut self, ctx: &mut Context) { let mut environment = self.env.lock(); + environment.add_nurc(); if environment.env().is_some() { for (name, value) in ctx.with_host(|host| host.vars()) { if name != "path" && name != "PATH" { @@ -70,8 +71,6 @@ impl EnvironmentSyncer { } } } - - environment.add_nurc(); } pub fn sync_path_vars(&mut self, ctx: &mut Context) {