Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions e2e/cli/test_upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,44 @@ assert "ls $MISE_DATA_DIR/installs/dummy/1.0.0"
mise up
assert_contains "mise up --dry-run-code 2>&1" "All tools are up to date"

# Test: upgrade should not re-download a version that is already installed
# This verifies the fix for https://github.com/jdx/mise/discussions/8260
cat <<EOF >mise.toml
[tools]
dummy = "1"
EOF
mise uninstall dummy --all
# Install 1.0.0 first (old version), then also install 1.1.0 (the latest 1.x)
mise install dummy@1.0.0
mise install dummy@1.1.0
assert_contains "mise ls --installed dummy" "1.0.0"
assert_contains "mise ls --installed dummy" "1.1.0"
# upgrade should report "All tools are up to date" since 1.1.0 is already installed
assert_contains "mise up 2>&1" "All tools are up to date"

# Test: upgrade with lockfile should update the lockfile to the new version
cat <<EOF >mise.toml
[tools]
dummy = "1"
EOF
mise uninstall dummy --all
mise install dummy@1.0.0
# Write a lockfile pinning to 1.0.0
cat <<EOF >mise.lock
[[tools.dummy]]
version = "1.0.0"
backend = "asdf:dummy"
EOF
# Verify the lockfile pins to 1.0.0
assert "mise ls dummy" "dummy 1.0.0 ~/workdir/mise.toml 1"
# Upgrade should install 1.1.0 and update the lockfile
mise up
assert "mise ls dummy" "dummy 1.1.0 ~/workdir/mise.toml 1"
# Verify the lockfile was updated to 1.1.0
assert_contains "cat mise.lock" "1.1.0"
assert_not_contains "cat mise.lock" "1.0.0"
rm -f mise.lock

# Test that upgrading a specific tool doesn't check other tools
# This verifies the fix for https://github.com/jdx/mise/discussions/7328
cat <<EOF >mise.toml
Expand Down
11 changes: 11 additions & 0 deletions src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,17 @@ pub trait Backend: Debug + Send + Sync {
if let Some(install_path) = tv.request.install_path(config)
&& check_path(&install_path, true)
{
// For Prefix requests, install_path finds any installed dir
// matching the prefix (e.g., "1.0.0" for prefix "1"), but if
// the ToolVersion resolved to a different version (e.g., "1.1.0"),
// we must not treat it as installed.
if let ToolRequest::Prefix { .. } = &tv.request
&& install_path
.file_name()
.is_some_and(|f| f.to_string_lossy() != tv.version)
{
return check_path(&tv.install_path(), check_symlink);
}
return true;
}
check_path(&tv.install_path(), check_symlink)
Expand Down
3 changes: 1 addition & 2 deletions src/cli/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ impl Upgrade {

let opts = InstallOptions {
reason: "upgrade".to_string(),
// TODO: can we remove this without breaking e2e/cli/test_upgrade? it may be causing tools to re-install
force: true,
force: false,
jobs: self.jobs,
raw: self.raw,
resolve_options: ResolveOptions {
Expand Down
Loading