Skip to content

Package Management

Package repositories

The MSYS2 software distribution uses a port of pacman (known from Arch Linux) to manage (install, remove and update) binary packages and also to build those packages in the first place.

Packages in MSYS2 work like packages in popular Linux distributions. A package is an archive containing a piece of software. This normally means executable files, runtime libraries, data, shared and static link libraries, header files, config files, and manual pages. Packages also contain metadata, such as the software's name, description of its purpose, version number, vendor, checksum, and a list of dependencies necessary for the software to run properly. Upon installation, the files contained are extracted into your MSYS2 installation directory and the metadata are stored in a local database.

There are 3 package repositories, msys2, mingw32, and mingw64. The packages in msys2 are named just like on a Linux distribution, the packages in mingw are prefixed by either mingw-w64-i686- for 32-bit packages, or mingw-w64-x86_64- for 64-bit packages.

Finding a package

If you want to find a specific package in the repository (and that package can or cannot be installed on your machine) you can use the following command:

pacman -Ss <name or part of the name of the package>

Example:

$ pacman -Ss openjp

mingw32/mingw-w64-i686-openjpeg 1.5.2-7
    An open source JPEG 2000 codec (mingw-w64)
mingw32/mingw-w64-i686-openjpeg2 2.1.0-7
    An open source JPEG 2000 codec (mingw-w64)
mingw64/mingw-w64-x86_64-openjpeg 1.5.2-7
    An open source JPEG 2000 codec (mingw-w64)
mingw64/mingw-w64-x86_64-openjpeg2 2.1.0-7 [installed]
    An open source JPEG 2000 codec (mingw-w64)

As you can see the mingw-w64-x86_64-openjpeg2 package is installed, while the mingw-w64-x86_64-openjpeg package is not installed.

If you would like to search only among the packages which has been already installed, use the following command:

pacman -Qs <name or part of the name of the package>

Installing a package

If you wan to install a package, use the following command:

pacman -S <name of the package>

If the package has dependencies which are not installed, pacman will ask you whether you would like to install the dependencies in the first place.

pacman -S also accepts virtual package names and package group names. Virtual package names can be often encountered with packages built from Git, e.g. msys2-launcher-git can be installed by requesting msys-launcher. Package groups simplify installation of related packages, e.g. install base-devel to get basic development tools. Please note that neither of those are real packages, so the commands below won't accept these names and you need to use the real package names instead.

Uninstalling a package

The following command will remove a package (but not its dependencies nor any files produced by running it):

pacman -R <name of the package>

Installing a specific version of a package or a stand-alone packages

Older (or pre-release) versions of packages can be installed directly from the package archive (.tar.zst or .tar.xz). The data store for the repositories contains older versions of packages, but beware that you might need to recursively find correct versions of dependencies for the desired package. Once downloaded, the package can be installed like this:

pacman -U <packagefile.tar.zst>

or

pacman -U <packagefile.tar.xz>

Listing the content of a package

If you would like to know what has been installed as a part of a specific package use the following command:

pacman -Ql <name of the package>

Example:

$ pacman -Ql mingw-w64-x86_64-pugixml

mingw-w64-x86_64-pugixml /mingw64/
mingw-w64-x86_64-pugixml /mingw64/bin/
mingw-w64-x86_64-pugixml /mingw64/bin/libpugixml.dll
mingw-w64-x86_64-pugixml /mingw64/include/
mingw-w64-x86_64-pugixml /mingw64/include/pugixml-1.8/
mingw-w64-x86_64-pugixml /mingw64/include/pugixml-1.8/pugiconfig.hpp
mingw-w64-x86_64-pugixml /mingw64/include/pugixml-1.8/pugixml.hpp
mingw-w64-x86_64-pugixml /mingw64/lib/
mingw-w64-x86_64-pugixml /mingw64/lib/cmake/
mingw-w64-x86_64-pugixml /mingw64/lib/cmake/pugixml/
mingw-w64-x86_64-pugixml /mingw64/lib/cmake/pugixml/pugixml-config-noconfig.cmake
mingw-w64-x86_64-pugixml /mingw64/lib/cmake/pugixml/pugixml-config.cmake
mingw-w64-x86_64-pugixml /mingw64/lib/pkgconfig/
mingw-w64-x86_64-pugixml /mingw64/lib/pkgconfig/pugixml.pc
mingw-w64-x86_64-pugixml /mingw64/lib/pugixml-1.8/
mingw-w64-x86_64-pugixml /mingw64/lib/pugixml-1.8/libpugixml.dll.a

As you can see the package contains:

  • a binary executable library file (libpugixml.dll),
  • a static library (libpugixml.dll.a),
  • 2 header files (pugixml.hpp, pugiconfig.hpp),
  • 2 cmake files,
  • and a PKGCONFIG file (pugixml.pc).

Finding dependencies of a package

You can use pactree to figure out which packages are needed to make a package working properly:

$ pactree mingw-w64-x86_64-gettext

mingw-w64-x86_64-gettext
├─mingw-w64-x86_64-expat
├─mingw-w64-x86_64-gcc-libs
│ ├─mingw-w64-x86_64-gmp
│ ├─mingw-w64-x86_64-libwinpthread-git provides mingw-w64-x86_64-libwinpthread
│ └─mingw-w64-x86_64-gcc-libgfortran
│   └─mingw-w64-x86_64-gcc-libs
└─mingw-w64-x86_64-libiconv

Alternatively you can use pacman -Qi to get the list of direct dependencies of a package:

$ pacman -Qi mingw-w64-x86_64-gettext

Name            : mingw-w64-x86_64-gettext
Version         : 0.19.7-1
Description     : GNU internationalization library (mingw-w64)
[...]
Depends On      : mingw-w64-x86_64-expat  mingw-w64-x86_64-gcc-libs
                  mingw-w64-x86_64-libiconv

Finding out which package a file belongs to

Use the following command to trace a file back to its owning package:

pacman -Qo <full file path>

Note that this operation only compares the file paths, so proper capitalization and the .exe suffix (if applicable) is required. Also note that this works only on installed packages, it will not scan the whole package repositories.

Finding which package will install the file you need

The two recommended tools that can scan a repository and find packages that contain specific files are pacman -F and pkgfile. Below are examples of pacman -F usage:

Call pacman -Fy to update your package database. To find an exact match, call pacman -F <filename> (don't include the path in the filename). To find a substring match, call pacman -Fx <filename>.

Note that this operation only compares the file paths, so proper capitalization and the .exe suffix (if applicable) is required.

Avoiding writing long package names

Use pacboy to install mingw packages without having to type the long package names (install pacboy first using pacman -S pactoys if necessary). Examples:

$ pacboy -S x265:x
resolving dependencies...
looking for conflicting packages...

Packages (1) mingw-w64-x86_64-x265-2.3-1

Total Download Size:    0.97 MiB
Total Installed Size:  20.72 MiB

:: Proceed with installation? [Y/n]
$ pacboy -S x265:i
resolving dependencies...
looking for conflicting packages...

Packages (1) mingw-w64-i686-x265-2.3-1

Total Download Size:    0.97 MiB
Total Installed Size:  11.37 MiB

:: Proceed with installation? [Y/n]
$ pacboy -S x265:m
resolving dependencies...
looking for conflicting packages...

Packages (2) mingw-w64-i686-x265-2.3-1  mingw-w64-x86_64-x265-2.3-1

Total Download Size:    0.97 MiB
Total Installed Size:  32.09 MiB

:: Proceed with installation? [Y/n]

Resources