Skip to content

fix(task): honor MISE_CYGDRIVE_PREFIX for Git Bash, not only Cygwin#10190

Merged
jdx merged 2 commits into
jdx:mainfrom
JamBalaya56562:pr10190
Jun 2, 2026
Merged

fix(task): honor MISE_CYGDRIVE_PREFIX for Git Bash, not only Cygwin#10190
jdx merged 2 commits into
jdx:mainfrom
JamBalaya56562:pr10190

Conversation

@JamBalaya56562
Copy link
Copy Markdown
Contributor

@JamBalaya56562 JamBalaya56562 commented Jun 1, 2026

Problem

PR #10147 added Cygwin support to the Windows→Unix PATH conversion, with MISE_CYGDRIVE_PREFIX as an escape hatch for a non-default cygdrive automount root configured in /etc/fstab.

As pointed out in review feedback (thanks @lewis-yeung), the cygdrive automount mechanism is also present in MSYS2 / Git Bash (a Cygwin derivative), where the mount root is likewise configurable in /etc/fstab (default /, i.e. /c/...).

msys_drive_prefix_for returned an empty prefix immediately for any non-Cygwin bash and never read MISE_CYGDRIVE_PREFIX, so a Git Bash user with a custom automount root got a corrupted /c/... PATH with no way to fix it — the same class of bug #10147 set out to address, still present for Git Bash.

Fix

  • is_cygwin_shell now only selects the default prefix when no override is set: empty for Git Bash / MSYS2 (/c/...), /cygdrive for Cygwin (/cygdrive/c/...).
  • MISE_CYGDRIVE_PREFIX is now honored for both shells. The relative-value warning reports the shell-appropriate default.

No behavior change for existing users: Git Bash without an override still emits /c/..., Cygwin without an override still emits /cygdrive/c/.... The only new behavior is that a Git Bash user can now set a custom prefix.

Tests

  • Added test_maybe_convert_env_for_msys_shell_honors_cygdrive_prefix_for_git_bash (Git Bash + MISE_CYGDRIVE_PREFIX=/mnt/mnt/c/...).
  • Existing Git Bash (/c/...) and Cygwin (/cygdrive/...) tests still guard the defaults.
  • Verified the full binary builds and all path:: unit tests pass; the #[cfg(windows)] prefix logic was exercised standalone across all input combinations.

Follow-up to #10147.


This PR was generated by an AI coding assistant.

Summary by CodeRabbit

  • Documentation

    • Expanded Windows troubleshooting guide with clearer instructions for configuring cygdrive mount roots and using MISE_CYGDRIVE_PREFIX, including absolute-path requirements and behavior when set to "/".
  • Bug Fixes

    • Improved Windows PATH conversion for POSIX shells (Cygwin, MSYS2/Git Bash) to honor custom cygdrive prefixes and produce correct converted paths.

The cygdrive automount root is configurable via /etc/fstab in MSYS2 / Git
Bash too, not just Cygwin (Git Bash is a Cygwin derivative). The previous
msys_drive_prefix_for returned an empty prefix immediately for any non-Cygwin
bash and never read MISE_CYGDRIVE_PREFIX, so a Git Bash user with a custom
automount root got a corrupted /c/... PATH with no escape hatch.

is_cygwin_shell now only selects the default prefix when no override is set
(empty for Git Bash/MSYS2, /cygdrive for Cygwin); MISE_CYGDRIVE_PREFIX is
honored for both shells. Follow-up to jdx#10147 (review feedback).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ec2d7e1-531b-47a2-8fd7-a388f134c6fe

📥 Commits

Reviewing files that changed from the base of the PR and between ad8e3d4 and 86f802a.

📒 Files selected for processing (1)
  • src/task/task_executor.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/task/task_executor.rs

📝 Walkthrough

Walkthrough

This PR enhances Windows PATH conversion for POSIX shells by making cygdrive prefix detection shell-aware. The msys_drive_prefix_for function now dynamically computes whether to use /cygdrive (Cygwin) or /mnt (MSYS2/Git Bash) as the default prefix, improves warnings for invalid MISE_CYGDRIVE_PREFIX overrides, adds test coverage for Git Bash, and expands troubleshooting documentation.

Changes

Windows PATH Conversion for POSIX Shells

Layer / File(s) Summary
Dynamic shell-type-aware cygdrive prefix detection
src/task/task_executor.rs
msys_drive_prefix_for now detects whether the target program is Cygwin or MSYS2/Git Bash and computes the appropriate default cygdrive prefix (/cygdrive vs /mnt). Warning text for non-absolute MISE_CYGDRIVE_PREFIX values reflects the computed default. New test verifies Git Bash respects the MISE_CYGDRIVE_PREFIX override for path conversion.
Windows troubleshooting documentation
docs/troubleshooting.md
Expanded the custom cygdrive mount root subsection to explain shared behavior between Cygwin and Git Bash/MSYS2, document how to configure MISE_CYGDRIVE_PREFIX, and clarify the absolute-prefix requirement and special handling of MISE_CYGDRIVE_PREFIX=/.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit hops through Windows paths,
/cygdrive and /mnt at last align,
Git Bash now knows which way to go,
With prefix defaults so divine! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main fix: extending MISE_CYGDRIVE_PREFIX support to Git Bash in addition to Cygwin, which is the primary objective of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 1, 2026

Greptile Summary

This PR fixes msys_drive_prefix_for so that MISE_CYGDRIVE_PREFIX is respected for Git Bash / MSYS2 in addition to Cygwin; previously the function returned an empty prefix immediately for any non-Cygwin shell and never read the env var.

  • src/task/task_executor.rs: Removes the early-return for non-Cygwin shells; the default prefix is now selected by shell type ("" for Git Bash/MSYS2, /cygdrive for Cygwin) and then MISE_CYGDRIVE_PREFIX is applied on top for both. The fallback warning message is also updated to describe the shell-appropriate default. A new test covers the Git Bash + custom prefix path.
  • docs/troubleshooting.md: Updates the troubleshooting guide to document that MISE_CYGDRIVE_PREFIX works for both Cygwin and Git Bash / MSYS2, notes each shell's default mount root, and clarifies the MISE_CYGDRIVE_PREFIX=/ edge case.

Confidence Score: 5/5

Safe to merge — the change is a targeted, backwards-compatible extension of existing Windows PATH conversion logic with no behaviour change for current users.

The old early-return for non-Cygwin shells is cleanly replaced by a shell-aware default, MISE_CYGDRIVE_PREFIX is now read for both shell types, and the warning message correctly describes the fallback for each case. Existing Git Bash and Cygwin tests still pass, and a new test covers the previously-missing Git Bash + custom prefix path. The documentation update is accurate. No regressions are introduced.

No files require special attention.

Important Files Changed

Filename Overview
src/task/task_executor.rs Extends msys_drive_prefix_for so MISE_CYGDRIVE_PREFIX is honored for Git Bash / MSYS2, not only Cygwin; default selection and warning message are both shell-aware; new test covers the Git Bash override path.
docs/troubleshooting.md Documentation updated to mention MSYS2 / Git Bash alongside Cygwin, note each shell's default mount root, and clarify the MISE_CYGDRIVE_PREFIX=/ edge case.

Reviews (2): Last reviewed commit: "test(task): clarify per-shell fallback c..." | Re-trigger Greptile

Address Greptile P2: the comment in
test_maybe_convert_env_for_msys_shell_rejects_relative_cygdrive_prefix
described an unconditional fall back to `/cygdrive`, which is only true
for the Cygwin binary the test exercises. Git Bash falls back to an empty
prefix (the `/c/...` form). Reworded to reflect the per-shell default.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JamBalaya56562
Copy link
Copy Markdown
Contributor Author

The comment in test_maybe_convert_env_for_msys_shell_rejects_relative_cygdrive_prefix still says "fall back to the default /cygdrive instead"...

Good catch — fixed. The comment now states that the fallback is the shell's default: /cygdrive for the Cygwin binary the test exercises, and an empty prefix (the /c/... form) for Git Bash. The assertion is unchanged.

@jdx jdx merged commit 483aa0d into jdx:main Jun 2, 2026
34 checks passed
@JamBalaya56562 JamBalaya56562 deleted the pr10190 branch June 2, 2026 23:56
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.

2 participants