Skip to content

Commit e1b8ca4

Browse files
jdxclaude
andcommitted
fix(shim): revert shims directory check that caused hangs on macOS
Reverts cfcb555 which changed shim detection from checking the binary name to checking if argv[0] exists in the shims directory. This caused mise to hang on startup for some users because the filesystem check could block on slow/network filesystems, and could falsely detect mise itself as a shim. Fixes #8734 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6c26b90 commit e1b8ca4

File tree

3 files changed

+11
-35
lines changed

3 files changed

+11
-35
lines changed

e2e/cli/test_shims_args

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/env.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,16 @@ pub static IS_RUNNING_AS_SHIM: Lazy<bool> = Lazy::new(|| {
377377
return true;
378378
}
379379

380-
crate::shims::is_in_shims_dir()
380+
let bin_name = *MISE_BIN_NAME;
381+
!is_mise_binary(bin_name)
381382
});
382383

384+
/// Returns true if the given binary name refers to mise itself (not a shim).
385+
/// Handles "mise", "mise.exe", "mise.bat", "mise.cmd", "mise-doctor", etc.
386+
pub fn is_mise_binary(bin_name: &str) -> bool {
387+
bin_name == "mise" || bin_name.starts_with("mise.") || bin_name.starts_with("mise-")
388+
}
389+
383390
#[cfg(test)]
384391
pub static TERM_WIDTH: Lazy<usize> = Lazy::new(|| 80);
385392

src/shims.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ use tokio::task::JoinSet;
2323

2424
// executes as if it was a shim if the command is not "mise", e.g.: "node"
2525
pub async fn handle_shim() -> Result<()> {
26-
if *env::MISE_TOOL_STUB || !*env::IS_RUNNING_AS_SHIM {
26+
// TODO: instead, check if bin is in shims dir
27+
let bin_name = *env::MISE_BIN_NAME;
28+
if env::is_mise_binary(bin_name) || cfg!(test) {
2729
return Ok(());
2830
}
29-
let bin_name = *env::MISE_BIN_NAME;
3031
let mut config = Config::get().await?;
3132
let mut args = env::ARGS.read().unwrap().clone();
3233
env::PREFER_OFFLINE.store(true, Ordering::Relaxed);
@@ -592,15 +593,3 @@ async fn err_no_version_set(
592593
Err(eyre!(msg.trim().to_string()))
593594
}
594595
}
595-
596-
/// Check if the current process is running as a shim by verifying that a file
597-
/// with the same name as argv[0] exists in the shims directory.
598-
/// This is more robust than checking the binary name with `is_mise_binary()`,
599-
/// since package managers may rename the mise binary (e.g. "mise-2026.3.7")
600-
/// which would incorrectly match the "mise-" prefix.
601-
pub fn is_in_shims_dir() -> bool {
602-
let bin_name = *env::MISE_BIN_NAME;
603-
let shim_path = dirs::SHIMS.join(bin_name);
604-
// is_symlink() catches broken symlinks that .exists() would miss
605-
shim_path.is_symlink() || shim_path.exists()
606-
}

0 commit comments

Comments
 (0)