pathmsys2

Running clang64.exe or mingw64.exe incorrectly sets PATH


I have MSYS2 installed on my Windows computer. The installation package includes files such as mingw64.exe, clang64.exe, and others. According to this page, when running the corresponding executable file, we expect to use the appropriate environment.

However, in my case there is the following oddity:

  1. Run mingw64.exe -> $ echo $PATH out is /clang64/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

  2. Run clang64.exe -> $ echo $PATH out is /clang64/bin:/clang64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

  3. Run clangarm64.exe -> $ echo $PATH out is /clang64/bin:/clangarm64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

Thus, one way or another the clang compiler will be used, which is completely not expected

UPDATE

According to the recommendations of ChatGPT, I tested the $MSYSTEM variable:

  1. Run mingw64.exe -> echo $MSYSTEM -> MINGW64
  2. Run clang64.exe -> echo $MSYSTEM -> CLANG64

The result is correct


Solution

  • It is not normal to have /clang64/bin on your PATH when you run mingw64.exe. There must be a startup script somewhere that is adding it.

    Run the following command to look for any mentions of clang64 in the startup scripts:

    grep -n clang64 /etc/profile /etc/profile.d/* ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc
    

    If that doesn't illuminate anything, you might have to look more carefully at those scripts to see what they are doing. You can also try putting echo $PATH commands at various points in those scripts to debug them.