diff --git a/src/backend/asdf.rs b/src/backend/asdf.rs index a8d40387f8..23c37df550 100644 --- a/src/backend/asdf.rs +++ b/src/backend/asdf.rs @@ -244,7 +244,7 @@ impl Backend for AsdfBackend { Some(PluginType::Asdf) } - fn get_dependencies(&self, tvr: &ToolRequest) -> Result> { + fn get_dependencies(&self, tvr: &ToolRequest) -> Result> { let out = match tvr.ba().tool_name.as_str() { "poetry" | "pipenv" | "pipx" => vec!["python"], "elixir" => vec!["erlang"], diff --git a/src/backend/cargo.rs b/src/backend/cargo.rs index 83566f2467..1060f2e6b7 100644 --- a/src/backend/cargo.rs +++ b/src/backend/cargo.rs @@ -32,7 +32,7 @@ impl Backend for CargoBackend { &self.ba } - fn get_dependencies(&self, _tvr: &ToolRequest) -> eyre::Result> { + fn get_dependencies(&self, _tvr: &ToolRequest) -> eyre::Result> { Ok(vec![ "rust".into(), "cargo-binstall".into(), diff --git a/src/backend/go.rs b/src/backend/go.rs index 769ed81254..e749473f80 100644 --- a/src/backend/go.rs +++ b/src/backend/go.rs @@ -24,7 +24,7 @@ impl Backend for GoBackend { &self.ba } - fn get_dependencies(&self, _tvr: &ToolRequest) -> eyre::Result> { + fn get_dependencies(&self, _tvr: &ToolRequest) -> eyre::Result> { Ok(vec!["go".into()]) } diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 7677f380f3..8cf220bbaa 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -168,18 +168,18 @@ pub trait Backend: Debug + Send + Sync { } /// If any of these tools are installing in parallel, we should wait for them to finish /// before installing this tool. - fn get_dependencies(&self, _tvr: &ToolRequest) -> eyre::Result> { + fn get_dependencies(&self, _tvr: &ToolRequest) -> eyre::Result> { Ok(vec![]) } - fn get_all_dependencies(&self, tvr: &ToolRequest) -> eyre::Result> { + fn get_all_dependencies(&self, tvr: &ToolRequest) -> eyre::Result> { let mut deps: IndexSet<_> = self .get_dependencies(tvr)? .into_iter() - .filter(|ba| self.ba() != ba) // prevent infinite loop + .filter(|short| self.ba().short != *short) // prevent infinite loop .collect(); let dep_backends = deps .iter() - .flat_map(|ba| ba.backend()) + .flat_map(|short| get(&short.into())) .collect::>(); for dep in dep_backends { // TODO: pass the right tvr @@ -244,16 +244,6 @@ pub trait Backend: Debug + Send + Sync { }; match tv.request { ToolRequest::System { .. } => true, - ToolRequest::Prefix { .. } => { - // can't use tv.request.install_path() in this case since it may point to a version - // that matches the prefix but is not the correct one. For example, in the following - // scenario this would not upgrade tiny because "prefix:1" would still match and - // `mise up` would think it is installed - // mise install tiny@1.0.0 - // mise use tiny@prefix:1 - // mise up tiny - check_path(&tv.install_path()) - } _ => { if let Some(install_path) = tv.request.install_path() { if check_path(&install_path) { @@ -352,7 +342,7 @@ pub trait Backend: Debug + Send + Sync { if !deps.is_empty() { trace!("Ensuring dependencies installed for {}", self.id()); let config = Config::get(); - let ts = config.get_tool_request_set()?.filter_by_tool(&deps); + let ts = config.get_tool_request_set()?.filter_by_tool(deps); let missing = ts.missing_tools(); if !missing.is_empty() { bail!( @@ -556,7 +546,7 @@ pub trait Backend: Debug + Send + Sync { .collect(); let mut ts: Toolset = config .get_tool_request_set()? - .filter_by_tool(&dependencies) + .filter_by_tool(dependencies) .into(); ts.resolve()?; Ok(ts) diff --git a/src/backend/npm.rs b/src/backend/npm.rs index 6ec2fdd7b3..5c85ba0cff 100644 --- a/src/backend/npm.rs +++ b/src/backend/npm.rs @@ -28,7 +28,7 @@ impl Backend for NPMBackend { &self.ba } - fn get_dependencies(&self, _tvr: &ToolRequest) -> eyre::Result> { + fn get_dependencies(&self, _tvr: &ToolRequest) -> eyre::Result> { Ok(vec!["node".into(), "bun".into()]) } diff --git a/src/backend/pipx.rs b/src/backend/pipx.rs index 6c0ca3e0ff..aa77eb5145 100644 --- a/src/backend/pipx.rs +++ b/src/backend/pipx.rs @@ -31,7 +31,7 @@ impl Backend for PIPXBackend { &self.ba } - fn get_dependencies(&self, _tvr: &ToolRequest) -> eyre::Result> { + fn get_dependencies(&self, _tvr: &ToolRequest) -> eyre::Result> { Ok(vec!["pipx".into(), "uv".into()]) } diff --git a/src/backend/spm.rs b/src/backend/spm.rs index e8ad03881d..69a2f4449b 100644 --- a/src/backend/spm.rs +++ b/src/backend/spm.rs @@ -34,10 +34,7 @@ impl Backend for SPMBackend { &self.ba } - fn get_dependencies( - &self, - _tvr: &crate::toolset::ToolRequest, - ) -> eyre::Result> { + fn get_dependencies(&self, _tvr: &crate::toolset::ToolRequest) -> eyre::Result> { // TODO: swift as dependencies (wait for swift core plugin: https://github.com/jdx/mise/pull/1708) Ok(vec![]) } diff --git a/src/backend/ubi.rs b/src/backend/ubi.rs index 8f769a5f64..61724f4e9a 100644 --- a/src/backend/ubi.rs +++ b/src/backend/ubi.rs @@ -7,7 +7,6 @@ use crate::env::GITHUB_TOKEN; use crate::github; use crate::install_context::InstallContext; use crate::plugins::VERSION_REGEX; -use crate::toolset::ToolRequest; use eyre::bail; use regex::Regex; use std::fmt::Debug; @@ -31,10 +30,6 @@ impl Backend for UbiBackend { &self.ba } - fn get_dependencies(&self, _tvr: &ToolRequest) -> eyre::Result> { - Ok(vec![]) - } - fn _list_remote_versions(&self) -> eyre::Result> { if name_is_url(self.name()) { Ok(vec!["latest".to_string()]) diff --git a/src/backend/vfox.rs b/src/backend/vfox.rs index 4a8a5ca3af..8173ed80a4 100644 --- a/src/backend/vfox.rs +++ b/src/backend/vfox.rs @@ -98,7 +98,7 @@ impl Backend for VfoxBackend { .collect()) } - fn get_dependencies(&self, tvr: &ToolRequest) -> eyre::Result> { + fn get_dependencies(&self, tvr: &ToolRequest) -> eyre::Result> { let out = match tvr.ba().tool_name.as_str() { "poetry" | "pipenv" | "pipx" => vec!["python"], "elixir" => vec!["erlang"], diff --git a/src/cli/install.rs b/src/cli/install.rs index 91aa76434b..2baea73655 100644 --- a/src/cli/install.rs +++ b/src/cli/install.rs @@ -1,4 +1,4 @@ -use crate::cli::args::{BackendArg, ToolArg}; +use crate::cli::args::ToolArg; use crate::config::Config; use crate::lockfile; use crate::toolset::{ @@ -7,7 +7,6 @@ use crate::toolset::{ use crate::ui::multi_progress_report::MultiProgressReport; use eyre::{Result, WrapErr}; use itertools::Itertools; -use std::collections::HashSet; /// Install a tool version /// @@ -59,8 +58,8 @@ impl Install { fn install_runtimes(&self, config: &Config, runtimes: &[ToolArg]) -> Result> { let mpr = MultiProgressReport::get(); - let tools: HashSet = runtimes.iter().map(|ta| ta.ba.clone()).collect(); - let mut ts = config.get_tool_request_set()?.filter_by_tool(&tools).into(); + let tools = runtimes.iter().map(|ta| ta.ba.short.clone()).collect(); + let mut ts = config.get_tool_request_set()?.filter_by_tool(tools).into(); let tool_versions = self.get_requested_tool_versions(&ts, runtimes)?; if tool_versions.is_empty() { warn!("no runtimes to install"); diff --git a/src/cli/upgrade.rs b/src/cli/upgrade.rs index 3abb338be9..01aadff049 100644 --- a/src/cli/upgrade.rs +++ b/src/cli/upgrade.rs @@ -136,7 +136,8 @@ impl Upgrade { return Ok(()); } let opts = InstallOptions { - force: false, + // TODO: can we remove this without breaking e2e/cli/test_upgrade? it may be causing tools to re-install + force: true, jobs: self.jobs, raw: self.raw, resolve_options: ResolveOptions { diff --git a/src/toolset/mod.rs b/src/toolset/mod.rs index b786560ac4..133e4d71bd 100644 --- a/src/toolset/mod.rs +++ b/src/toolset/mod.rs @@ -674,7 +674,10 @@ impl From for Toolset { } fn get_leaf_dependencies(requests: &[ToolRequest]) -> eyre::Result> { - let versions_hash = requests.iter().map(|tr| tr.ba()).collect::>(); + let versions_hash = requests + .iter() + .map(|tr| tr.ba().short.to_string()) + .collect::>(); let leaves = requests .iter() .map(|tr| { diff --git a/src/toolset/tool_request.rs b/src/toolset/tool_request.rs index f95c714c61..50bfb5b720 100644 --- a/src/toolset/tool_request.rs +++ b/src/toolset/tool_request.rs @@ -181,7 +181,7 @@ impl ToolRequest { } self } - pub fn dependencies(&self) -> eyre::Result> { + pub fn dependencies(&self) -> eyre::Result> { let backend = self.ba().backend()?; backend.get_all_dependencies(self) } diff --git a/src/toolset/tool_request_set.rs b/src/toolset/tool_request_set.rs index a3d3cd4077..ff7a83c460 100644 --- a/src/toolset/tool_request_set.rs +++ b/src/toolset/tool_request_set.rs @@ -7,6 +7,7 @@ use itertools::Itertools; use crate::cli::args::{BackendArg, ToolArg}; use crate::config::{Config, Settings}; use crate::env; +use crate::registry::REGISTRY; use crate::toolset::{ToolRequest, ToolSource}; #[derive(Debug, Default, Clone)] @@ -73,9 +74,15 @@ impl ToolRequestSet { }) } - pub fn filter_by_tool(&self, tools: &HashSet) -> Self { + pub fn filter_by_tool(&self, mut tools: HashSet) -> ToolRequestSet { + // add in the full names so something like cargo:cargo-binstall can be used in place of cargo-binstall + for short in tools.clone().iter() { + if let Some(rt) = REGISTRY.get(short.as_str()) { + tools.extend(rt.backends().iter().map(|s| s.to_string())); + } + } self.iter() - .filter(|(fa, ..)| tools.contains(fa)) + .filter(|(ba, ..)| tools.contains(&ba.short)) .map(|(fa, trl, ts)| (fa.clone(), trl.clone(), ts.clone())) .collect::() }