diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 04f06d9021..fde85f7ec5 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -603,7 +603,8 @@ pub trait Backend: Debug + Send + Sync { } fn dependency_env(&self) -> eyre::Result> { - self.dependency_toolset()?.full_env() + let config = Config::get(); + self.dependency_toolset()?.full_env(&config) } fn fuzzy_match_filter(&self, versions: Vec, query: &str) -> eyre::Result> { diff --git a/src/cli/completion.rs b/src/cli/completion.rs index e43929e9b8..e5a0fbee8a 100644 --- a/src/cli/completion.rs +++ b/src/cli/completion.rs @@ -67,7 +67,10 @@ impl Completion { if self.include_bash_completion_lib { args.push("--include-bash-completion-lib".into()); } - let output = cmd("usage", args).full_env(toolset.full_env()?).read()?; + let config = Config::get(); + let output = cmd("usage", args) + .full_env(toolset.full_env(&config)?) + .read()?; Ok(output) } diff --git a/src/cli/doctor/mod.rs b/src/cli/doctor/mod.rs index b7a355b688..0de0aebefa 100644 --- a/src/cli/doctor/mod.rs +++ b/src/cli/doctor/mod.rs @@ -373,7 +373,8 @@ impl Doctor { } fn paths(&mut self, ts: &Toolset) -> eyre::Result> { - let env = ts.full_env()?; + let config = Config::get(); + let env = ts.full_env(&config)?; let path = env .get(&*PATH_KEY) .ok_or_else(|| eyre::eyre!("Path not found"))?; diff --git a/src/hooks.rs b/src/hooks.rs index 819cabf179..f6534e4a6a 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -161,7 +161,8 @@ fn execute(ts: &Toolset, root: &Path, hook: &Hook) -> Result<()> { .map(|s| s.as_str()) .chain(once(hook.script.as_str())) .collect_vec(); - let mut env = ts.full_env()?; + let config = Config::get(); + let mut env = ts.full_env(&config)?; if let Some(cwd) = dirs::CWD.as_ref() { env.insert( "MISE_ORIGINAL_CWD".to_string(), diff --git a/src/toolset/mod.rs b/src/toolset/mod.rs index d88c4e6823..4bf9309cb6 100644 --- a/src/toolset/mod.rs +++ b/src/toolset/mod.rs @@ -463,9 +463,9 @@ impl Toolset { .collect() } /// returns env_with_path but also with the existing env vars from the system - pub fn full_env(&self) -> Result { + pub fn full_env(&self, config: &Config) -> Result { let mut env = env::PRISTINE_ENV.clone().into_iter().collect::(); - env.extend(self.env_with_path(&Config::get())?.clone()); + env.extend(self.env_with_path(config)?.clone()); Ok(env) } /// the full mise environment including all tool paths @@ -590,7 +590,7 @@ impl Toolset { pub fn tera_ctx(&self) -> Result<&tera::Context> { self.tera_ctx.get_or_try_init(|| { let config = Config::get(); - let env = self.env_with_path(&config)?; + let env = self.full_env(&config)?; let mut ctx = config.tera_ctx.clone(); ctx.insert("env", &env); Ok(ctx) diff --git a/src/watch_files.rs b/src/watch_files.rs index 403ab3b387..15d1aebf4a 100644 --- a/src/watch_files.rs +++ b/src/watch_files.rs @@ -67,7 +67,8 @@ fn execute(ts: &Toolset, root: &Path, run: &str, files: Vec<&PathBuf>) -> Result .map(|s| s.as_str()) .chain(once(run)) .collect_vec(); - let mut env = ts.full_env()?; + let config = Config::get(); + let mut env = ts.full_env(&config)?; env.insert("MISE_WATCH_FILES_MODIFIED".to_string(), modified_files_var); if let Some(cwd) = &*dirs::CWD { env.insert(