Skip to content

fix(windows): correctly identify mise binary without extension#8503

Merged
jdx merged 1 commit intomainfrom
fix-win-shim-check
Mar 7, 2026
Merged

fix(windows): correctly identify mise binary without extension#8503
jdx merged 1 commit intomainfrom
fix-win-shim-check

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Mar 7, 2026

Summary

  • Fixes the same issue as fix(windows): correctly identify mise binary without extension #8496 with the cleanup requested by @jdx
  • On Windows, argv[0] can resolve to mise (without .exe), mise.bat, or mise.cmd, all of which were incorrectly identified as shims
  • Simplifies the IS_RUNNING_AS_SHIM logic by removing #[cfg(unix)]/#[cfg(windows)] blocks and using a single unified check
  • Extracts a shared is_mise_binary() helper used by both IS_RUNNING_AS_SHIM and handle_shim() to keep the logic in one place

Credit to @salim-b for identifying and reporting the issue in #8496.

Co-Authored-By: Salim B git@salim.space

Test plan

  • Verify mise --help and mise --version work correctly on Windows when argv[0] is mise (without extension)
  • Verify shim behavior still works (e.g., node shim correctly identified as a shim)
  • Verify 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 to mise without an extension (or to mise.bat/mise.cmd), which previously caused real mise invocations to be treated as shims.

This replaces the platform-specific comparison logic in IS_RUNNING_AS_SHIM with a shared env::is_mise_binary() helper and updates handle_shim() to use the same check, ensuring consistent behavior for mise, mise.*, and mise-... binaries.

Written by Cursor Bugbot for commit 566183a. This will update automatically on new commits. Configure here.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 mise executable was incorrectly classified as a shim when executed without its file extension. The core change involves simplifying and unifying the shim detection mechanism, making it more resilient to platform-specific invocation nuances and ensuring the main mise binary and its subcommands are always correctly recognized, thereby preventing unexpected behavior.

Highlights

  • Windows Binary Identification: Corrected an issue where the mise binary on Windows, when invoked without a file extension (e.g., mise instead of mise.exe), was erroneously identified as a shim.
  • Simplified Shim Logic: Refactored the IS_RUNNING_AS_SHIM logic to remove platform-specific #[cfg(unix)] and #[cfg(windows)] blocks, creating a single, unified check.
  • Robust Binary Name Check: Enhanced the binary name comparison to correctly identify the main mise executable (with or without extensions like .exe, .bat, .cmd) and mise- prefixed subcommands as non-shims.
Changelog
  • src/env.rs
    • Removed conditional compilation for mise_bin based on #[cfg(unix)] and #[cfg(windows)].
    • Modified the IS_RUNNING_AS_SHIM boolean expression to explicitly check for "mise", names starting with "mise.", and names starting with "mise-".
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a Windows-specific bug where argv[0] could resolve to mise (without .exe), mise.bat, or mise.cmd, all of which were incorrectly classified as shims under the old platform-gated check. It extracts a single is_mise_binary() helper used by both IS_RUNNING_AS_SHIM and handle_shim(), replacing a fragile #[cfg(unix)] / #[cfg(windows)] split with a unified, cross-platform predicate.

Key changes:

  • is_mise_binary(bin_name) returns true for "mise", any "mise." prefix (Windows extensions), and "mise-" prefix (subcommand aliases)
  • IS_RUNNING_AS_SHIM now simply uses !is_mise_binary(bin_name) — no more platform guards
  • handle_shim() replaces the overly-broad starts_with("mise") with the new helper, so bizarrely-named binaries like "miseXYZ" are now correctly treated as shims rather than being silently ignored

Test coverage: No unit tests are added for is_mise_binary; given it is the single source of truth for shim detection and is now pub, adding a small test block would guard against future regressions.

Confidence Score: 4/5

  • Safe to merge; the fix is correct and strictly improves Windows shim detection with no regressions on Unix.
  • The logic change is small, well-reasoned, and directly addresses the reported bug. The only concern is the absence of unit tests for the new public is_mise_binary() function, which is now the central logic for shim detection.
  • src/env.rs — the new is_mise_binary function would benefit from unit tests

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"]
Loading

Fix All in Claude Code

Last reviewed commit: 566183a

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 7, 2026

Hyperfine Performance

mise x -- echo

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>
@jdx jdx force-pushed the fix-win-shim-check branch from 00d2851 to 566183a Compare March 7, 2026 18:21
Comment on lines +285 to +287
pub fn is_mise_binary(bin_name: &str) -> bool {
bin_name == "mise" || bin_name.starts_with("mise.") || bin_name.starts_with("mise-")
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
    }
}

Fix in Claude Code

@jdx jdx enabled auto-merge (squash) March 7, 2026 18:30
@jdx jdx merged commit 855b084 into main Mar 7, 2026
38 checks passed
@jdx jdx deleted the fix-win-shim-check branch March 7, 2026 18:34
jdx pushed a commit that referenced this pull request Mar 7, 2026
### 🚀 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant