msys2: not finding windows programs despite (MSYS2_PATH_TYPE = inherit)
Asked Answered
S

3

23

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

Selfrealization answered 30/7, 2017 at 20:56 Comment(2)
Don't post images for this purpose. Text takes less time to readSetser
Did you ever figure this out?Juniorjuniority
U
37

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.

Undermine answered 22/6, 2018 at 16:39 Comment(5)
msys2_shell.cmd -use-full-path works for me but MSYS2_PATH_TYPE=inherit not.Sears
same for me, MSYS2_PATH_TYPE=inherit does not work for meBranks
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.Amiraamis
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 -> CommandsLeaving
it has different .init file correspondingly for each type of terminal. check the installation folder. my case is using ucrt64.cmd(so changed the ucrt64.init)Propend
A
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

Afterwards answered 8/3, 2023 at 2:37 Comment(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/npmAbdominous
A
1

You must uncomment MSYS2_PATH_TYPE=inherit specifically for the configuration file of the environment you're using.

For example, if you're using the UCRT64 environment, you must uncomment MSYS2_PATH_TYPE=inherit in the ucrt64.ini file instead of msys2.ini.

Aquatint answered 22/12, 2023 at 21:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.