Fixes · Checked on 2026-10-03
mklink: Invalid switch from Git Bash
Git Bash rewrote your switch before cmd saw it.
The error
$ cmd //c mklink /J models 'C:\data\models'
Invalid switch - "models".
Why it happens
Git Bash turns arguments that look like Unix paths into Windows paths before it starts a Windows program.
That's why cmd's own /c has to be written //c. /J gets the same
treatment, so mklink's arguments no longer line up and it rejects the next one as a switch.
The fix
Double the slash, as with //c:
cmd //c mklink //J models 'C:\data\models'
Or turn the rewriting off for one command:
MSYS_NO_PATHCONV=1 cmd /c mklink /J models 'C:\data\models'
Or make the junction from PowerShell, which wants an absolute target:
New-Item -ItemType Junction -Path models -Target C:\data\models
Write the target with backslashes, in quotes. In ../data/models, mklink reads /data
as another switch and rejects it.
To remove a junction later, cmd /c rmdir models removes the link alone. Never delete through it
recursively: that deletes the files it points to.
How DMN learned it
It came up, and was fixed, in 2 of our own sessions. DMN kept the fix as one line:
Running `cmd //c mklink /J` from Git Bash fails with 'Invalid switch' because MSYS mangles the args; run
`cmd /c mklink /J "<link>" "<target>"` from PowerShell with absolute Windows paths.
DMN reads your agents' past sessions on your machine. When the same error is fixed the same way in two or more of them, it keeps the fix as a one-line lesson. When the error turns up again, Claude Code is told the fix straight away, and any agent can search what earlier sessions found. How DMN keeps what agents learn.