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

Syfer
  • 4,262
  • 3
  • 20
  • 37
Mya256
  • 311
  • 1
  • 2
  • 3

2 Answers2

32

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.

holzkohlengrill
  • 1,044
  • 19
  • 29
Andrey
  • 1,752
  • 18
  • 17
  • 4
    `msys2_shell.cmd -use-full-path` works for me but `MSYS2_PATH_TYPE=inherit` not. – UltimaWeapon Nov 27 '20 at 06:59
  • 2
    same for me, `MSYS2_PATH_TYPE=inherit` does not work for me – kennyvh Feb 04 '21 at 05: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 '21 at 09: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 '22 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

  • 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 '23 at 08:23