Skip to content

Commit

Permalink
feat: show instructions for updating when min_version does not match (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx authored Dec 13, 2024
1 parent 5fc9d9d commit 284d676
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mod render_help;
mod render_mangen;
mod reshim;
mod run;
mod self_update;
pub(crate) mod self_update;
mod set;
mod settings;
mod shell;
Expand Down
21 changes: 14 additions & 7 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use eyre::{ensure, eyre, Context, Result};
use eyre::{bail, eyre, Context, Result};
use indexmap::{IndexMap, IndexSet};
use itertools::Itertools;
use once_cell::sync::{Lazy, OnceCell};
Expand Down Expand Up @@ -33,6 +33,7 @@ pub mod env_directive;
pub mod settings;
pub mod tracking;

use crate::cli::self_update::SelfUpdate;
use crate::hook_env::WatchFilePattern;
use crate::hooks::Hook;
use crate::plugins::PluginType;
Expand Down Expand Up @@ -521,12 +522,18 @@ impl Config {
for cf in self.config_files.values() {
if let Some(min) = cf.min_version() {
let cur = &*version::V;
ensure!(
cur >= min,
"mise version {} is required, but you are using {}",
style::eyellow(min),
style::eyellow(cur)
);
if cur < min {
let min = style::eyellow(min);
let cur = style::eyellow(cur);
if SelfUpdate::is_available() {
bail!(
"mise version {min} is required, but you are using {cur}\n\
Run `mise self update` to update mise",
);
} else {
bail!("mise version {min} is required, but you are using {cur}");
}
}
}
}
Ok(())
Expand Down

0 comments on commit 284d676

Please sign in to comment.