From fed4930f77b91b41cab052a4ea294c343d3686f6 Mon Sep 17 00:00:00 2001 From: Kevin Swiber Date: Mon, 13 Apr 2026 10:29:06 -0700 Subject: [PATCH 1/2] fix(shim): use which_no_shims when resolving mise binary in reshim and doctor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When shims are on PATH (e.g. non-interactive shells using `mise activate --shims`), `file::which("mise")` finds the mise shim instead of the real binary. This causes `reshim` to create circular symlinks (mise shim pointing to itself) and `doctor` to falsely report all shims as missing. Use `file::which_no_shims` which already exists for this purpose — it filters the shims directory from PATH before searching. --- e2e/cli/test_reshim_with_shims_on_path | 44 ++++++++++++++++++++++++++ src/cli/doctor/mod.rs | 2 +- src/shims.rs | 2 +- 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100755 e2e/cli/test_reshim_with_shims_on_path diff --git a/e2e/cli/test_reshim_with_shims_on_path b/e2e/cli/test_reshim_with_shims_on_path new file mode 100755 index 0000000000..7bb1f66bb8 --- /dev/null +++ b/e2e/cli/test_reshim_with_shims_on_path @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# Regression test: when shims are on PATH and a "mise" shim exists (e.g. because +# core:rust is managed and ~/.cargo/bin contains the mise binary), +# `mise reshim` should still create shims pointing to the real mise binary, +# not to the mise shim itself (which would create a circular symlink). +# Similarly, `mise doctor` should not report shims as missing. + +shimdir="$MISE_DATA_DIR/shims" +mise_bin="$(which mise)" + +# Install a tool so there are shims to create +mise i dummy@latest + +# Reshim without shims on PATH — baseline +mise reshim + +# Verify shim was created and points to the real binary +assert "readlink $shimdir/dummy" "$mise_bin" + +# Simulate what happens when core:rust is in the toolset: the mise binary +# itself ends up with a shim because ~/.cargo/bin (containing mise) is scanned +# as a tool bin directory. Create a mise shim pointing to the real binary. +ln -sf "$mise_bin" "$shimdir/mise" + +# Now put shims on PATH (as mise activate --shims does in non-interactive shells) +export PATH="$shimdir:$PATH" + +# Reshim WITH shims on PATH and a mise shim present. +# Previously this caused file::which("mise") to find the shim, leading to +# circular symlinks (shim pointing to itself) and broken doctor output. +mise reshim + +# Shim should still point to the real mise binary, not to the shim directory +assert "readlink $shimdir/dummy" "$mise_bin" +assert_not_contains "readlink $shimdir/dummy" "$shimdir" + +# The mise shim itself must not be circular +if [ -L "$shimdir/mise" ]; then + assert_not_contains "readlink $shimdir/mise" "$shimdir" +fi + +# Doctor should not report missing shims +assert_not_contains "mise doctor" "shims are missing" diff --git a/src/cli/doctor/mod.rs b/src/cli/doctor/mod.rs index 930be24d1e..26616bd131 100644 --- a/src/cli/doctor/mod.rs +++ b/src/cli/doctor/mod.rs @@ -385,7 +385,7 @@ impl Doctor { } async fn analyze_shims(&mut self, config: &Arc, toolset: &Toolset) { - let mise_bin = file::which("mise").unwrap_or(env::MISE_BIN.clone()); + let mise_bin = file::which_no_shims("mise").unwrap_or(env::MISE_BIN.clone()); if let Ok((missing, extra)) = shims::get_shim_diffs(config, mise_bin, toolset).await { let cmd = style::nyellow("mise reshim"); diff --git a/src/shims.rs b/src/shims.rs index 70f310185f..1648d108be 100644 --- a/src/shims.rs +++ b/src/shims.rs @@ -124,7 +124,7 @@ pub async fn reshim(config: &Arc, ts: &Toolset, force: bool) -> Result<( }) .lock(); - let mise_bin = file::which("mise").unwrap_or(env::MISE_BIN.clone()); + let mise_bin = file::which_no_shims("mise").unwrap_or(env::MISE_BIN.clone()); let mise_bin = mise_bin.absolutize()?; // relative paths don't work as shims #[cfg(windows)] From dc4a7384b91d5b29aab0b23f9be1489399cda098 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 17:33:35 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- e2e/cli/test_reshim_with_shims_on_path | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/cli/test_reshim_with_shims_on_path b/e2e/cli/test_reshim_with_shims_on_path index 7bb1f66bb8..3dfa7b1bb0 100755 --- a/e2e/cli/test_reshim_with_shims_on_path +++ b/e2e/cli/test_reshim_with_shims_on_path @@ -37,7 +37,7 @@ assert_not_contains "readlink $shimdir/dummy" "$shimdir" # The mise shim itself must not be circular if [ -L "$shimdir/mise" ]; then - assert_not_contains "readlink $shimdir/mise" "$shimdir" + assert_not_contains "readlink $shimdir/mise" "$shimdir" fi # Doctor should not report missing shims