fix(windows): correctly identify mise binary without extension#8503
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical bug affecting Windows users where the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Greptile SummaryThis PR fixes a Windows-specific bug where Key changes:
Test coverage: No unit tests are added for Confidence Score: 4/5
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["argv[0] / MISE_BIN_NAME"] --> B["is_mise_binary(bin_name)?"]
B -->|"bin_name == 'mise'"| C["✅ Mise binary\n(not a shim)"]
B -->|"bin_name.starts_with('mise.')\ne.g. mise.exe, mise.bat, mise.cmd"| C
B -->|"bin_name.starts_with('mise-')\ne.g. mise-doctor"| C
B -->|"anything else\ne.g. node, python"| D["🔀 Shim\n(handle_shim runs)"]
C --> E["IS_RUNNING_AS_SHIM = false\nhandle_shim() returns early"]
D --> F["IS_RUNNING_AS_SHIM = true\nhandle_shim() executes shim logic"]
Last reviewed commit: 566183a |
There was a problem hiding this comment.
Code Review
This pull request fixes an issue on Windows where mise without an extension was incorrectly identified as a shim, simplifying the shim detection logic to be platform-agnostic. A security audit found no vulnerabilities in this change. However, a related inconsistency was identified in another part of the codebase that uses a similar but broader check, and it is recommended to update it for better consistency and to prevent potential bugs.
src/env.rs
Outdated
| let mise_bin = "mise.exe"; | ||
| let bin_name = *MISE_BIN_NAME; | ||
| bin_name != mise_bin && !bin_name.starts_with("mise-") | ||
| bin_name != "mise" && !bin_name.starts_with("mise.") && !bin_name.starts_with("mise-") |
There was a problem hiding this comment.
This new logic for identifying a non-shim mise invocation is more specific than the check in src/shims.rs:28, which uses a broader bin_name.starts_with("mise"). This inconsistency can lead to unexpected behavior. For example, a binary named miserable would not be executed as a shim by handle_shim(), but IS_RUNNING_AS_SHIM would be true.
To ensure consistent behavior across the application, I recommend aligning the logic in src/shims.rs with this more precise check:
// in src/shims.rs
if (bin_name == "mise" || bin_name.starts_with("mise.") || bin_name.starts_with("mise-")) || cfg!(test) {
return Ok(());
}This will make the shim detection more robust and predictable.
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.3.4 x -- echo |
23.9 ± 0.6 | 22.6 | 28.2 | 1.00 |
mise x -- echo |
24.0 ± 0.5 | 22.8 | 25.5 | 1.00 ± 0.03 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.3.4 env |
23.6 ± 0.9 | 22.2 | 30.3 | 1.00 ± 0.05 |
mise env |
23.5 ± 0.5 | 22.3 | 25.2 | 1.00 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.3.4 hook-env |
23.9 ± 0.5 | 22.9 | 25.6 | 1.00 |
mise hook-env |
24.1 ± 0.5 | 22.8 | 28.2 | 1.01 ± 0.03 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.3.4 ls |
23.1 ± 0.4 | 22.1 | 25.2 | 1.00 |
mise ls |
23.2 ± 0.4 | 22.3 | 26.1 | 1.00 ± 0.03 |
xtasks/test/perf
| Command | mise-2026.3.4 | mise | Variance |
|---|---|---|---|
| install (cached) | 150ms | 150ms | +0% |
| ls (cached) | 83ms | 83ms | +0% |
| bin-paths (cached) | 86ms | 86ms | +0% |
| task-ls (cached) | 820ms | 822ms | +0% |
On Windows, argv[0] can resolve to "mise" (without .exe), "mise.bat", or "mise.cmd", all of which were incorrectly identified as shims. Simplify IS_RUNNING_AS_SHIM by removing platform-specific #[cfg] blocks and extract a shared is_mise_binary() helper used by both IS_RUNNING_AS_SHIM and handle_shim(). Co-Authored-By: Salim B <git@salim.space> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| pub fn is_mise_binary(bin_name: &str) -> bool { | ||
| bin_name == "mise" || bin_name.starts_with("mise.") || bin_name.starts_with("mise-") | ||
| } |
There was a problem hiding this comment.
is_mise_binary is a new pub function containing the critical shim-detection logic, yet no unit tests are added. Since this function is now the single source of truth for distinguishing mise binaries from shims across both env.rs and shims.rs, it would be valuable to cover edge cases explicitly — especially the Windows-specific ones that motivated this PR.
A minimal test module would help prevent regressions:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_is_mise_binary() {
// direct invocations
assert!(is_mise_binary("mise"));
assert!(is_mise_binary("mise.exe"));
assert!(is_mise_binary("mise.bat"));
assert!(is_mise_binary("mise.cmd"));
// subcommand aliases
assert!(is_mise_binary("mise-doctor"));
assert!(is_mise_binary("mise-outdated"));
// shims must NOT match
assert!(!is_mise_binary("node"));
assert!(!is_mise_binary("python"));
assert!(!is_mise_binary("miseish")); // no separator → still a shim
}
}### 🚀 Features - **(vfox)** add `RUNTIME.envType` for libc variant detection by @malept in [#8493](#8493) - store provenance verification results in lockfile by @jdx in [#8495](#8495) ### 🐛 Bug Fixes - **(env)** skip remote version fetching for "latest" in prefer-offline mode by @jdx in [#8500](#8500) - **(tasks)** deduplicate shared deps across task delegation by @vadimpiven in [#8497](#8497) - **(windows)** correctly identify mise binary without extension by @jdx in [#8503](#8503) ### 🚜 Refactor - **(core)** migrate cmd! callers to async with kill_on_drop by @jdx in [a63f7d2](a63f7d2) ### Chore - **(ci)** temporarily disable `mise up` in release-plz by @jdx in [#8504](#8504) - consolidate all linters into hk.pkl by @jdx in [#8498](#8498) ## 📦 Aqua Registry Updates #### New Packages (1) - [`apache/ant`](https://github.com/apache/ant)
Summary
argv[0]can resolve tomise(without.exe),mise.bat, ormise.cmd, all of which were incorrectly identified as shimsIS_RUNNING_AS_SHIMlogic by removing#[cfg(unix)]/#[cfg(windows)]blocks and using a single unified checkis_mise_binary()helper used by bothIS_RUNNING_AS_SHIMandhandle_shim()to keep the logic in one placeCredit to @salim-b for identifying and reporting the issue in #8496.
Co-Authored-By: Salim B git@salim.space
Test plan
mise --helpandmise --versionwork correctly on Windows whenargv[0]ismise(without extension)nodeshim correctly identified as a shim)mise-prefixed subcommands are not treated as shims🤖 Generated with Claude Code
Note
Low Risk
Small, localized change to binary-name detection; main risk is misclassifying edge-case executable names and altering shim behavior in those cases.
Overview
Fixes Windows shim detection when
argv[0]resolves tomisewithout an extension (or tomise.bat/mise.cmd), which previously caused realmiseinvocations to be treated as shims.This replaces the platform-specific comparison logic in
IS_RUNNING_AS_SHIMwith a sharedenv::is_mise_binary()helper and updateshandle_shim()to use the same check, ensuring consistent behavior formise,mise.*, andmise-...binaries.Written by Cursor Bugbot for commit 566183a. This will update automatically on new commits. Configure here.