I did this like:
/c/tools/msys64/msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here -c 'COMMAND'
and it seemed to work. (There are other unrelated errors, though.)
UPDATE: The above does not reload PATH
from the Registry after Chocolatey has modified it during package installation. To do this interactively from a Git Bash window you’d need to run RefreshEnv.cmd
beforehand, like:
cmd.exe //C "RefreshEnv.cmd & C:/tools/msys64/msys2_shell.cmd" -defterm -mingw64 -no-start -full-path -here -c "COMMAND"
However, I encountered issues when setting the above to a wrapper $shell
environment variable for my job. The following eventually worked:
- export shell="cmd.exe //C RefreshEnv.cmd & C:/tools/msys64/msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here -c"
- $shell COMMAND
But if your command needs arguments, that won’t work either. You’ll then need:
- export shell="cmd.exe //C RefreshEnv.cmd & C:/tools/msys64/msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here -c \$\* --"
- $shell COMMAND ARG1 ARG2 ...
Final version working here.