Skip to content

fix(utils): normalize MSYS Git paths + add MSYS CI repro - #12288

Closed
ATKasem wants to merge 3 commits into
facebook:mainfrom
ATKasem:fix/msys-git-path-ci-repro
Closed

fix(utils): normalize MSYS Git paths + add MSYS CI repro#12288
ATKasem wants to merge 3 commits into
facebook:mainfrom
ATKasem:fix/msys-git-path-ci-repro

Conversation

@ATKasem

@ATKasem ATKasem commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Pre-flight checklist

Motivation

Fixes #11920.

On Windows under Git Bash / MSYS / Cygwin, git rev-parse --show-toplevel can return a POSIX drive path such as /c/msys-repro-site. getGitRepoRoot was passing that straight to fs.realpath.native, which resolves it against the current drive root and duplicates the drive letter (C:\c\msys-repro-site), so the eager Git VCS path fails with ENOENT.

What slorber asked for

Following #11920 (comment) and the review on #12067:

  1. MSYS/Cygwin CI workflow that validates the problem end to end (not just unit tests of a path helper)
  2. That CI job failing first
  3. Then the fix + unit tests
  4. Then that CI job passing

Commit / CI sequence

Step Commit MSYS CI
1. Repro only 5506fca — workflow + repro script, no fix failureENOENT: realpath 'C:\c\msys-repro-site' with git returning /c/msys-repro-site
2. Fix + unit tests 44f7c32 — normalize MSYS paths before realpath success

The fix

gitPosixDrivePathToWindows converts /<drive>/... mount paths to native Windows paths on win32 before fs.realpath.native in getGitRepoRoot and getGitSuperProjectRoot. Non-Windows platforms and non-drive POSIX paths are unchanged.

Test plan

  • New workflow: .github/workflows/msys-git-path-repro.yml using msys2/setup-msys2, runs admin/scripts/msys-git-path-repro/repro.mjs against the real compiled getGitRepoRoot
  • Unit tests for the conversion helper in gitUtils.test.ts
  • Linked red/green MSYS runs above

@slorber — does this match what you wanted for the MSYS/Cygwin CI validation path?

ATKasem added 2 commits July 16, 2026 11:05
Adds a windows-latest + msys2/setup-msys2 workflow that runs the real
getGitRepoRoot under an MSYS shell where git rev-parse --show-toplevel
returns /c/... paths. Without a fix this job is expected to fail with the
drive-duplication ENOENT from facebook#11920.
On Windows under MSYS/Git Bash, git rev-parse --show-toplevel can return
/c/... paths. Passing those to fs.realpath.native duplicates the drive
letter (C:\c\...) and breaks eager Git VCS. Normalize the mount path
first in getGitRepoRoot / getGitSuperProjectRoot, with unit tests for
the conversion helper.
@netlify

netlify Bot commented Jul 16, 2026

Copy link
Copy Markdown

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit d5936eb
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a5904b92aff970008c802ea
😎 Deploy Preview https://deploy-preview-12288--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@slorber slorber left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That's not good

Please don't use other bad PRs as inspiration for how to test this problem: the original issue reports running into this bug while running docusaurus build, not running new repro code you invent.

@@ -0,0 +1,167 @@
/**

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't want to have this kind of repro file

The original issue reported the bug while running docusaurus build

Please remove this file and make sure docusaurus build actually fails the build under MSYS

You are even stealing code from someone else's PR:
https://github.com/facebook/docusaurus/pull/12067/changes#diff-74d42521dbbadfcfa9876bacdc56b9a6105b61125b7cc88e6f2a7d3ff6ca8694

This code is wrong, and stealing code from someone else is wrong too

Comment on lines +78 to +102
- name: Create git repo and run repro
shell: msys2 {0}
run: |
set -euo pipefail
REPO_DIR="/c/msys-repro-site"
rm -rf "$REPO_DIR"
mkdir -p "$REPO_DIR"
cd "$REPO_DIR"
git init -q
git config user.email repro@example.com
git config user.name Repro
echo "# repro" > README.md
git add README.md
git commit -q -m "initial commit"
echo "git rev-parse --show-toplevel => $(git rev-parse --show-toplevel)"

# Native Windows Node needs native Windows paths for the script and
# cwd. The git that getGitRepoRoot shells out to is still the MSYS
# git on PATH, so it keeps returning the `/c/...` MSYS path.
WORKSPACE_UNIX="$(cygpath -u "${GITHUB_WORKSPACE}")"
REPO_DIR_WIN="$(cygpath -w "$REPO_DIR")"
SCRIPT_WIN="$(cygpath -w "${WORKSPACE_UNIX}/admin/scripts/msys-git-path-repro/repro.mjs")"
echo "repo dir (win) : ${REPO_DIR_WIN}"
echo "script (win) : ${SCRIPT_WIN}"
node "${SCRIPT_WIN}" "${REPO_DIR_WIN}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please reproduce the bug using docusaurus build, not an artificial repro script

@slorber slorber closed this Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Windows: incorrect path conversion from Git POSIX paths (/x/...) to Windows paths (X:\...)

2 participants