Skip to content

fix: run mklink through cmd so Windows npm install works - #7982

Merged
code-asher merged 1 commit into
coder:mainfrom
denusklo:fix-windows-mklink
Sep 4, 2026
Merged

fix: run mklink through cmd so Windows npm install works#7982
code-asher merged 1 commit into
coder:mainfrom
denusklo:fix-windows-mklink

Conversation

@denusklo

@denusklo denusklo commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

npm install on Windows (git-bash/MSYS) fails in postinstall with mklink: command not found. mklink is a cmd.exe builtin rather than an executable, so the sh running npm-postinstall.sh cannot exec it, and every symlink the install needs goes through this line.

Routing it through cmd //c fixes it. Verified on Windows 11: mklink /J link src from sh reports command not found, cmd //c mklink //J link src reports "Junction created" and a file reads correctly through the junction, using the same relative paths the symlink() call passes. The doubled slashes are MSYS argument escaping, safe here because this case only runs when the OS was detected as cygwin/mingw.

One of the failures behind the recipes in #1397.

npm install fails on Windows in postinstall with "mklink: command not
found". mklink is a cmd.exe builtin rather than an executable, so the sh
running this script cannot exec it, and every symlink the install needs is
made this way.

Routing it through cmd works. Verified on Windows 11 with git-bash: `mklink
/J link src` reports command not found, `cmd //c mklink //J link src`
reports "Junction created" and the junction resolves. Tested with the same
relative paths symlink() passes, from a directory it has cd'd into.

The doubled slashes are the usual MSYS escaping, and are safe here because
this branch only runs when the OS was detected as cygwin or mingw.
@denusklo
denusklo requested a review from a team as a code owner September 4, 2026 04:56

@code-asher code-asher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for finding this!

Actually, since this is for cygwin/wingw can we directly use ln?

Ah nevermind I tried in git bash and ln -s seems to just copy the file instead. 🤷

@code-asher
code-asher enabled auto-merge (squash) September 4, 2026 19:01
@code-asher
code-asher disabled auto-merge September 4, 2026 20:06
@code-asher
code-asher merged commit 62284ed into coder:main Sep 4, 2026
12 checks passed
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