Skip to content


You should not launch sh.exe directly as that doesn't start a login shell or set the correct environment variables for the type of shell that you want to use. Instead, your best choices are:

msys2_shell.cmd, the improved multi-purpose batch file from the filesystem package. Run msys2_shell.cmd --help for usage.

msys2.exe, mingw64.exe, mingw32.exe, the new pinnable launchers from the msys2-launcher package from @Elieux. GitHub, discussion, discussion

A nice explanation how to set up ConEmu to run MSYS2 inside it by jstine.

Configuration for an MSYS2 shell in Visual Studio Code.

msys2_env.bat from @DavidEGrayson. Gist, discussion

msys2.cmd, mingw64.cmd, mingw32.cmd from @Elieux. Gist

smart_msys from @jhasse. GitHub, discussion

MSYS2 here, MINGW64 here and MINGW32 here Explorer context menu items from @Elieux. Gist

msystem.bat and cmd/clink integration in the filesystem-cmd package from @userzimmermann. PR, commits

git-bash.exe and start-ssh-agent.cmd as part of the Git for Windows project from @dscho. GitHub, GitHub

Open MSYS2 here from @magthe, with contributions from @sushovan-dw and @ryanpfeeley. Gist+discussion

msys2_shell.bat, mingw64_shell.bat and mingw32_shell.bat, the old-school batch files from old versions of the filesystem package.

The idea

If you need to start a shell correctly, but none of the ways above suit you, devise your own way based on this knowledge:

  • set MSYSTEM=... into the environment, with the value of either MSYS, MINGW32, or MINGW64
  • then run a login shell

The typical one-liner if your options are limited is C:\\msys64\\usr\\bin\\env MSYSTEM=MSYS /usr/bin/bash -li.


  • MSYS2 inherits multi-user capabilities from Cygwin and there is a notion of user's default shell. Not everyone's default shell is bash. To correctly figure out the default shell from outside (i.e. without directly calling the POSIX APIs), you can use this shell one-liner or an equivalent: getent passwd $(whoami) | cut -d: -f7
  • There are other environment variables that control MSYS2 at runtime or initialization. See the source of launchers above to figure them out if needed.
  • You might need to set CHERE_INVOKING=1 for the shell to stay in the current working directory.
  • If you need to run a specific command instead of an interactive shell, you still need to go through a login shell, e.g. ... /usr/bin/bash -lc python.