Skip to content

fix(vcs): handle MSYS/Git Bash POSIX paths on Windows - #12341

Open
yash2277-ctrl wants to merge 1 commit into
facebook:mainfrom
yash2277-ctrl:fix/windows-msys-git-path-conversion
Open

fix(vcs): handle MSYS/Git Bash POSIX paths on Windows#12341
yash2277-ctrl wants to merge 1 commit into
facebook:mainfrom
yash2277-ctrl:fix/windows-msys-git-path-conversion

Conversation

@yash2277-ctrl

@yash2277-ctrl yash2277-ctrl commented Aug 7, 2026

Copy link
Copy Markdown

Summary

This PR fixes a critical bug on Windows where builds fail due to incorrect Git POSIX path conversion.

Fixes

Closes #11920

Problem

When using Git on Windows with MSYS/Git Bash, git rev-parse --show-toplevel returns POSIX-style paths like /p/projets/my-repo. However, fs.realpath() expects Windows paths like P:\projets\my-repo, causing builds to fail with:

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

Solution

Added normalizeMSYSPath() function that:

  • Only runs on Windows (process.platform === 'win32')
  • Detects MSYS-style paths matching /[drive]/...
  • Converts them to proper Windows format DRIVE:...
  • Applies conversion before calling fs.realpath()

Changes

  • Added normalizeMSYSPath() helper function
  • Modified getGitRepoRoot() to normalize paths
  • Modified getGitSuperProjectRoot() to normalize paths

Testing

This fix addresses the exact pattern described in #11920:

  • Input: /p/projets/my-repo
  • Output: P:\projets\my-repo

Impact

  • Fixes builds on Windows with Git Bash/MSYS
  • No impact on Linux/macOS
  • No impact on Windows with non-MSYS Git
  • Backward compatible (only affects specific Windows+MSYS scenario)

Type of Change

Fixes facebook#11920%0A%0AGit on Windows (when using MSYS/Git Bash) returns POSIX-style paths like /p/projets/... which need to be converted to Windows paths like P:\projets\... before being used with fs.realpath()%0A%0AThis commit adds a normalizeMSYSPath() function that:%0A- Detects Windows platform%0A- Matches MSYS paths pattern (/[drive letter]/...)%0A- Converts to proper Windows format (DRIVE:\...)%0A- Applies the conversion in getGitRepoRoot() and getGitSuperProjectRoot()%0A%0AThis prevents 'ENOENT: no such file or directory' errors when building Docusaurus sites on Windows with Git Bash.
@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Aug 7, 2026
@netlify

netlify Bot commented Aug 7, 2026

Copy link
Copy Markdown

[V2]

Built without sensitive environment variables

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

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

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