Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include full env in toolset tera_ctx #3751

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading