Skip to content

Commit

Permalink
fix: elixir installation failed (#4144)
Browse files Browse the repository at this point in the history
* fix: elixir installation failed

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
roele and autofix-ci[bot] authored Jan 25, 2025
1 parent 77367ca commit 668d152
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/cli/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(())
Expand Down
1 change: 1 addition & 0 deletions src/cli/use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/env.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -14,6 +14,7 @@ use std::sync::RwLock;
use std::{path, process};

pub static ARGS: RwLock<Vec<String>> = RwLock::new(vec![]);
pub static TOOL_ARGS: RwLock<Vec<ToolArg>> = RwLock::new(vec![]);
#[cfg(unix)]
pub static SHELL: Lazy<String> = Lazy::new(|| var("SHELL").unwrap_or_else(|_| "sh".into()));
#[cfg(windows)]
Expand Down
14 changes: 14 additions & 0 deletions src/toolset/tool_request_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
Expand Down

0 comments on commit 668d152

Please sign in to comment.