Skip to content

Commit

Permalink
fix: move semver cmp errors to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Nov 25, 2024
1 parent e1b1b48 commit 450c302
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
3 changes: 3 additions & 0 deletions e2e/backend/test_pipx_deep_dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ mise install
# Assert that mkdocs 1.6.0 has been installed with pipx and uses python 3.12
# (mkdocs conveniently returns its installation path in with --version)
assert_contains "mise x -- mkdocs --version" "/mise/installs/pipx-mkdocs/1.6.0/venvs/mkdocs/lib/python3.12/"

mise up --bump python@3.12
assert_contains "mise x -- mkdocs --version" "/mise/installs/pipx-mkdocs/1.6.0/venvs/mkdocs/lib/python3.12/"
1 change: 0 additions & 1 deletion src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ pub trait Backend: Debug + Send + Sync {
}

fn list_remote_versions(&self) -> eyre::Result<Vec<String>> {
self.warn_if_dependencies_missing()?;
self.get_remote_version_cache()
.get_or_try_init(|| {
trace!("Listing remote versions for {}", self.ba().to_string());
Expand Down
32 changes: 31 additions & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::file::display_path;
use crate::shorthands::{get_shorthands, Shorthands};
use crate::task::Task;
use crate::toolset::{
install_state, ToolRequestSet, ToolRequestSetBuilder, ToolVersion, ToolsetBuilder,
install_state, ToolRequestSet, ToolRequestSetBuilder, ToolVersion, Toolset, ToolsetBuilder,
};
use crate::ui::style;
use crate::{backend, dirs, env, file, lockfile, registry, runtime_symlinks, shims};
Expand All @@ -33,7 +33,10 @@ pub mod env_directive;
pub mod settings;
pub mod tracking;

use crate::backend::backend_type::BackendType;
use crate::cmd::CmdLineRunner;
use crate::plugins::PluginType;
use crate::ui::multi_progress_report::MultiProgressReport;
pub use settings::SETTINGS;

type AliasMap = IndexMap<String, Alias>;
Expand All @@ -53,6 +56,7 @@ pub struct Config {
shorthands: OnceLock<Shorthands>,
tasks: OnceCell<BTreeMap<String, Task>>,
tool_request_set: OnceCell<ToolRequestSet>,
toolset: OnceCell<Toolset>,
}

#[derive(Debug, Clone, Default)]
Expand Down Expand Up @@ -189,6 +193,14 @@ impl Config {
self.tool_request_set
.get_or_try_init(|| ToolRequestSetBuilder::new().build())
}
#[allow(unused)]
pub fn get_toolset(&self) -> eyre::Result<&Toolset> {
self.toolset.get_or_try_init(|| {
let mut ts = Toolset::from(self.get_tool_request_set()?.clone());
ts.resolve()?;
Ok(ts)
})
}

pub fn get_repo_url(&self, plugin_name: &str) -> Option<String> {
let plugin_name = self
Expand Down Expand Up @@ -913,6 +925,24 @@ pub fn rebuild_shims_and_runtime_symlinks(new_versions: &[ToolVersion]) -> Resul
trace!("updating lockfiles");
lockfile::update_lockfiles(&config, &ts, new_versions)
.wrap_err("failed to update lockfiles")?;

if new_versions.iter().any(|v| v.short() == "python") {
let pipx_tools = ts
.list_installed_versions()?
.into_iter()
.filter(|(b, tv)| b.ba().backend_type() != BackendType::Pipx);
let mpr = MultiProgressReport::get();
for (b, tv) in pipx_tools {
CmdLineRunner::new("pipx")
.arg("reinstall")
.arg(&b.ba().short)
.envs(ts.env_with_path(&config)?)
.prepend_path(ts.list_paths())?
.with_pr(&mpr.add(&format!("reinstalling pipx tool {tv}")))
.execute()?;
}
}

Ok(())
}

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/core/python.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::backend::backend_type::BackendType;
use crate::backend::{Backend, VersionCacheManager};
use crate::build_time::built_info;
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::{Config, SETTINGS};
use crate::config::{Config, CONFIG, SETTINGS};
use crate::file::{display_path, TarFormat, TarOptions};
use crate::git::Git;
use crate::http::{HTTP, HTTP_FETCH};
Expand Down
4 changes: 4 additions & 0 deletions src/toolset/tool_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ impl ToolVersion {
self.ba().backend()
}

pub fn short(&self) -> &str {
&self.ba().short
}

pub fn install_path(&self) -> PathBuf {
let pathname = match &self.request {
ToolRequest::Path { path: p, .. } => p.to_string_lossy().to_string(),
Expand Down

0 comments on commit 450c302

Please sign in to comment.