Skip to content

Commit

Permalink
fix: include full env in toolset tera_ctx (#3751)
Browse files Browse the repository at this point in the history
* fix: include full env in toolset tera_ctx

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
risu729 and autofix-ci[bot] authored Dec 21, 2024
1 parent c59fedf commit 69a3fd6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,8 @@ pub trait Backend: Debug + Send + Sync {
}

fn dependency_env(&self) -> eyre::Result<BTreeMap<String, String>> {
self.dependency_toolset()?.full_env()
let config = Config::get();
self.dependency_toolset()?.full_env(&config)
}

fn fuzzy_match_filter(&self, versions: Vec<String>, query: &str) -> eyre::Result<Vec<String>> {
Expand Down
5 changes: 4 additions & 1 deletion src/cli/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
3 changes: 2 additions & 1 deletion src/cli/doctor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ impl Doctor {
}

fn paths(&mut self, ts: &Toolset) -> eyre::Result<Vec<PathBuf>> {
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"))?;
Expand Down
3 changes: 2 additions & 1 deletion src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions src/toolset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<EnvMap> {
pub fn full_env(&self, config: &Config) -> Result<EnvMap> {
let mut env = env::PRISTINE_ENV.clone().into_iter().collect::<EnvMap>();
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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/watch_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 69a3fd6

Please sign in to comment.