21

Using MSYS2 64-bit version 20161025 on Windows 10...

I'm unable to get msys2 to recognize programs in the windows path. For example, after installing Go version 1.8.3 using the windows the installer: (1) Cygwin finds go.exe (2) the Windows command prompt finds go.exe but (3) MSYS2 does not.

Please refer to attached image. Thanks in advance. enter image description here

2
  • 1
    Don't post images for this purpose. Text takes less time to read
    – hagello
    Jul 31, 2017 at 0:27
  • Did you ever figure this out? Jan 11, 2018 at 22:23

2 Answers 2

33

Run msys2_shell.cmd -use-full-path

or

uncomment MSYS2_PATH_TYPE=inherit in msys2.ini (can be found in the installation directory of MSYS2).


Related GitHub issue regarding the inherit flag.

4
  • 4
    msys2_shell.cmd -use-full-path works for me but MSYS2_PATH_TYPE=inherit not. Nov 27, 2020 at 6:59
  • 2
    same for me, MSYS2_PATH_TYPE=inherit does not work for me
    – kennyvh
    Feb 4, 2021 at 5:20
  • 2
    uncommenting MSYS2_PATH_TYPE=inherit in mingw64.ini worked for me when running mingw64.exe. I would assume the same would apply for mingw32.ini and msys2.ini depending on which executable you are running.
    – limco
    Sep 16, 2021 at 9:36
  • If using conemu/cmder you may need to set variable in call. Nothing else worked until I added & set MSYS2_PATH_TYPE=inherit under Startup -> Tasks -> Msys2-64 -> Commands
    – AnnanFay
    Sep 14, 2022 at 19:07
2

I just added the paths I wanted to access from Msys2 into the .bash_profile file in home/{my user name}/. That works. I just used Notepad++ in Windows to edit, but you can use nano or vim as well.

I couldn't get the "inherit" in the .ini file to work, or the msys2 shell cmd (which opened another terminal window with the same path as what I started out with) to work either.

I didn't really want the whole Windows path anyway, it has the bin folder for Git for Windows (a crippled MingW64 build) and I thought weird stuff might happen.

The file looks looks like this:

# User dependent .bash_profile file

# source the users bashrc if it exists
if [ -f "${HOME}/.bashrc" ] ; then
  source "${HOME}/.bashrc"
fi

# Add Coretto Java 11 and Windows Python to path
PATH="${PATH}:/c/batch:/c/Program Files/Python310/Scripts/:/c/Program Files/Python310/:/c/Program Files/Amazon Corretto/jdk11.0.16_9/bin"

Remember to change C:\ to /c/ and all backslashes to forward slashes. Use colons to separate paths, not semicolons. Surround the path with quotes. Use ${PATH} to keep the existing path to all those /bin/ directories. Spaces in the directory names are fine.

Here is what I get in the Msys2 terminal:

StephanPeters@Stephan-HPZBook15G4-Y4E78AV MSYS ~
# java --version
openjdk 11.0.16.1 2022-08-12 LTS
OpenJDK Runtime Environment Corretto-11.0.16.9.1 (build 11.0.16.1+9-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.16.9.1 (build 11.0.16.1+9-LTS, mixed mode)

StephanPeters@Stephan-HPZBook15G4-Y4E78AV MSYS ~
# which java
/c/Program Files/Amazon Corretto/jdk11.0.16_9/bin/java

StephanPeters@Stephan-HPZBook15G4-Y4E78AV MSYS ~
#

Path in use: Msys2

1
  • I did exactly the same since I don(t want the whole Windows %PATH% in my msys2 $PATH - in my situation I needed to add /c/Users/username/AppData/Roaming/npm
    – Emmanuel
    Apr 14 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.