Skip to content

fix(utils): getGitRepoRoot should convert MSYS/Git-Bash paths on Windows#12269

Open
ATKasem wants to merge 1 commit into
facebook:mainfrom
ATKasem:fix/git-repo-root-msys-windows-path
Open

fix(utils): getGitRepoRoot should convert MSYS/Git-Bash paths on Windows#12269
ATKasem wants to merge 1 commit into
facebook:mainfrom
ATKasem:fix/git-repo-root-msys-windows-path

Conversation

@ATKasem

@ATKasem ATKasem commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Pre-flight checklist

Motivation

Fixes #11920.

On Windows under Git Bash / MSYS, git rev-parse --show-toplevel returns a POSIX-style drive path such as /p/projets/my-repo. getGitRepoRoot (packages/docusaurus-utils/src/vcs/gitUtils.ts) passes that string directly to fs.realpath.native. Node interprets the leading /p/ as relative to the current drive root and resolves it to P:\p\projets\my-repo, so realpath throws:

ENOENT: no such file or directory, realpath 'P:\p\projets\my-repo'

and the build fails. This is reachable through the eager Git VCS logic (future.faster.gitEagerVcs).

Test Plan

Fix: convert MSYS/Git-Bash POSIX drive paths (/c/...C:\...) to native Windows paths before resolving, via a small pure helper gitPosixDrivePathToWindows. It's applied in getGitRepoRoot only when process.platform === 'win32', so real POSIX paths on macOS/Linux are untouched.

New unit tests in gitUtils.test.ts cover the helper:

  • /p/projets/my-repoP:\projets\my-repo, /c/Users/me/websiteC:\Users\me\website
  • drive root only: /d/D:\
  • native Windows paths (C:/already/windows) and non-drive-mount POSIX paths (/home/user/repo, /usr/local/lib) pass through unchanged

The existing getGitRepoRoot suite still passes (44 tests total). pnpm build (tsc) and ESLint are clean.

Test links

n/a — internal Git path handling, no UI change.

Deploy preview: n/a

@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Jul 10, 2026
@netlify

netlify Bot commented Jul 10, 2026

Copy link
Copy Markdown

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit aff6e19
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a515506fc1eee00095a46d5
😎 Deploy Preview https://deploy-preview-12269--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.

On Windows under Git Bash / MSYS, `git rev-parse --show-toplevel` returns a
POSIX-style drive path such as `/p/projets/my-repo`. `getGitRepoRoot` passed this
straight to `fs.realpath.native`, and Node interprets the leading `/p/` as
relative to the current drive root, resolving it to `P:\p\projets\my-repo`. That
makes `realpath` throw `ENOENT` and breaks the build (reachable via the eager
Git VCS logic, `future.faster.gitEagerVcs`).

Convert MSYS drive paths (`/c/...` -> `C:\...`) before resolving, gated on
`process.platform === 'win32'` so real POSIX paths on macOS/Linux are untouched.

Closes facebook#11920
@ATKasem ATKasem force-pushed the fix/git-repo-root-msys-windows-path branch from d598e07 to aff6e19 Compare July 10, 2026 20:24
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:\...)

1 participant