'MSYS2' / 'Mingw' Notes
Downloading the 'MSYS2' Installer
An installer for a package that only runs on 64 bit Windows but can also build binaries for 32 bit Windows can be downloaded at
Download file msys2-x86_64-20221216.exe or newer.
Hints for Windows 7 Only
Development of an MSYS2/Mingw package that runs on 32 bit Windows has been discontinued, but earlier packages are still available at
Download file msys2-i686-20200517.exe, which is the latest version.
Running the Downloaded Installer
Open a console window, change to the download directory, and run the downloaded .exe
file to install the base packet.
The installer adds some new entries to the Windows start menu, and you have to click on one of those to open a command line window
with the preferred build environment settings. See next chapter.
Opening a Shell in a Selected Build Environment
Klick on the menu entry for the preferred build environment to open an associated console Window.
The default environment for fresh installations seems to be MSYS2 UCRT64
now, but MSYS2 MINGW32
and MSYS2 MINGW64
have been successfully used in the past to build native applications that run on 32 bit and 64 bit Windows versions.
A description of the different build environments can be found here:
- MSYS2 Environments
https://www.msys2.org/docs/environments/
Upgrading the Installation
The MSYS2 system uses the pacman
program to maintain installed packages.
In current installations, it should be sufficient to run
pacman -Syuu
within any of the MSYS2 shells (maybe multiple times after each other) to upgrade all components to the latest versions.
Note for Windows 7: in an installation on Windows 7 32 bit the command updated some basic programs, then asked to
close the msys shell and re-open it before continuing by repeating the command. However, it was impossible
to re-open a new shell until the machine had been rebooted. So the older way described below for older versions
may be generally preferred.
In older installations, updates may need to be run in 2 steps:
First update programs that may be in use:
pacman --needed -S bash pacman pacman-mirrors msys2-runtime
If any packages have been updated, you have to close and re-run the MSYS2 shell before continuing.
Then run
pacman -Syu
to update the remaining packages.
Installing Additional Packages
Installing Development Tools
Toolchain to build 32 bit Windows binaries:
pacman -S --needed base-devel mingw-w64-i686-toolchain
Toolchain to build 64 bit Windows binaries (can be used on 64 bit Windows only):
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
meld, the excellent graphical diff and merge tool:
pacman -S --needed mingw-w64-i686-meld3 # The 32 bit version. pacman -S --needed mingw-w64-x86_64-meld3 # The 64 bit version.
git & gitk:
pacman -S --needed git
This package may be required only if the graphical toool gitk
fails to start:
pacman -S --needed mingw-w64-i686-tk # The 32 bit version. pacman -S --needed mingw-w64-x86_64-tk # The 64 bit version.
If you want to use git
to not only clone remote repos, you may want to do some
basic git configuration
that greatly simplifies working with git
.
Git Configuration
Git for Windows
is a different package based on MSYS2/Mingw, but uses a different configuration for the shell and for git.
To avoid problems when working with a Mingw32 or Mingw64 shell in a directory containing a git repo cloned (or maintained) by Git for Windows
,
some configuration files should be copied from the Git for Windows
installation directory (e.g. /c/opt/git/
)
to the Msys installation directory (e.g. /c/opt/msys32/
), namely:
/etc/gitconfig
/etc/gitattibutes
/etc/profile.d/git-prompt.sh
Among other things, this avoids that different line endings are assumed by the different git installations in Git for Windows
and Msys2/Mingw.
Invalid or Missing Package PGP/GPG Keys
If an error occurs because a PGP key is missing or has expired, the hints in this paragraph may help to fix the problem.
Note: In the examples below, a WKD key server is explicitly specified because
older installations may use the obsolete pool.
If a PGP key is missing or has expired, run the following command to refresh all keys:
pacman-key --keyserver hkp://keyserver.ubuntu.com:80 --refresh-keys
It's possible that the command above has to be run several times to fetch all required keys.
If a key is still missing or can't be updated automatically, import the key manually:
pacman-key --keyserver hkp://keyserver.ubuntu.com:80 -r 5F944B027F7FE2091985AA2EFA11531AA0AA7F57
Then edit the key to increase the trust level. Run
pacman-key --edit-key 5F944B027F7FE2091985AA2EFA11531AA0AA7F57
then enter trust
, select level 4 (full), and enter save
to save the changes.
Note: in an installation on Windows 7 32 bit level 4 was not saved. The increased trust level was only saved when level '5' (ultimate) was selected.
Car must also be taken that the appropriate key for 'y' is pressed (in German, 'j') to accept the level.
Then repeat the command from the basic installation
pacman -Syu
— Martin Burnicki martin.burnicki@burnicki.net, last updated 2022-12-21