From 668d152c9cfcd9fdb7789c9e40edeacec4338994 Mon Sep 17 00:00:00 2001 From: Roland Schaer Date: Sat, 25 Jan 2025 15:53:22 +0100 Subject: [PATCH] fix: elixir installation failed (#4144) * fix: elixir installation failed * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- src/cli/install.rs | 7 +++++-- src/cli/use.rs | 1 + src/env.rs | 3 ++- src/toolset/tool_request_set.rs | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/cli/install.rs b/src/cli/install.rs index 784d7de4a8..6944774183 100644 --- a/src/cli/install.rs +++ b/src/cli/install.rs @@ -3,7 +3,7 @@ use crate::config::Config; use crate::hooks::Hooks; use crate::toolset::{InstallOptions, ResolveOptions, ToolRequest, ToolSource, Toolset}; use crate::ui::multi_progress_report::MultiProgressReport; -use crate::{config, hooks}; +use crate::{config, env, hooks}; use eyre::Result; use itertools::Itertools; @@ -49,7 +49,10 @@ impl Install { pub fn run(self) -> Result<()> { let config = Config::try_get()?; match &self.tool { - Some(runtime) => self.install_runtimes(&config, runtime)?, + Some(runtime) => { + env::TOOL_ARGS.write().unwrap().clone_from(runtime); + self.install_runtimes(&config, runtime)? + } None => self.install_missing_runtimes(&config)?, }; Ok(()) diff --git a/src/cli/use.rs b/src/cli/use.rs index 9668a54908..129b15f546 100644 --- a/src/cli/use.rs +++ b/src/cli/use.rs @@ -101,6 +101,7 @@ impl Use { if self.tool.is_empty() && self.remove.is_empty() { self.tool = vec![self.tool_selector()?]; } + env::TOOL_ARGS.write().unwrap().clone_from(&self.tool); let config = Config::try_get()?; let mut ts = ToolsetBuilder::new() .with_global_only(self.global) diff --git a/src/env.rs b/src/env.rs index fc29317ada..bb543dc80e 100644 --- a/src/env.rs +++ b/src/env.rs @@ -1,4 +1,4 @@ -use crate::cli::args::{ENV_ARG, PROFILE_ARG}; +use crate::cli::args::{ToolArg, ENV_ARG, PROFILE_ARG}; use crate::env_diff::{EnvDiff, EnvDiffOperation, EnvDiffPatches, EnvMap}; use crate::file::replace_path; use crate::shell::ShellType; @@ -14,6 +14,7 @@ use std::sync::RwLock; use std::{path, process}; pub static ARGS: RwLock> = RwLock::new(vec![]); +pub static TOOL_ARGS: RwLock> = RwLock::new(vec![]); #[cfg(unix)] pub static SHELL: Lazy = Lazy::new(|| var("SHELL").unwrap_or_else(|_| "sh".into())); #[cfg(windows)] diff --git a/src/toolset/tool_request_set.rs b/src/toolset/tool_request_set.rs index cb17e37325..7562916538 100644 --- a/src/toolset/tool_request_set.rs +++ b/src/toolset/tool_request_set.rs @@ -227,6 +227,20 @@ impl ToolRequestSetBuilder { } merge(trs, arg_ts); } + + let tool_args = env::TOOL_ARGS.read().unwrap(); + let mut arg_trs = ToolRequestSet::new(); + for arg in tool_args.iter() { + if let Some(tvr) = &arg.tvr { + arg_trs.add_version(tvr.clone(), &ToolSource::Argument); + } else if !trs.tools.contains_key(&arg.ba) { + // no active version, so use "latest" + let tr = ToolRequest::new(arg.ba.clone(), "latest", ToolSource::Argument)?; + arg_trs.add_version(tr, &ToolSource::Argument); + } + } + merge(trs, arg_trs); + Ok(()) } }