How to set PATH inside MinGW64 environment

I followed the guide to set up an MSYS2/MinGW64 environment on Windows.

Our build scripts are installing binaries into a defined location that needs to be added to the PATH in order for subsequent commands to find the executables. On Unix, one would just export PATH=... to add this location, but it seems that this is not passed on into the MinGW64 environment.

Is there a way to edit the PATH environment variable for the MinGW64 environment, so that different commands run using the $mingw64 prefix will pick it up?

Thanks!

To answer my own question for future Windows noobs like myself: here’s how to edit the PATH in the MinGW environment:

setx -m PATH "C:\my\path;%PATH%"

This can be run without the $mingw64 prefix.

1 Like

Another way to set it for just one command:

$mingw64 PATH=/c/my/path:$PATH command arg1 arg2 ...
Imprint