Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extend $PATH variable in git bash under Windows

I'm trying to extend my $PATH variable in git bash (MinGW shell) by adding the following to the file ~/.bashrc

PATH=$PATH':/c/Program Files/maven/apache-maven-3.2.5/bin' 

After I did this and restarted the bash it seems like that the $PATH variable was extended like expected:

$ echo $PATH MANY_OTHER_PATHS:/c/Program Files/maven/apache-maven-3.2.5/bin 

But I still cannot execute the programms in the given directory:

$ mvn bash: mvn: command not found 

What went wrong here? How do I extend the PATH variable correctly?

like image 593
eztam Avatar asked Aug 31 '17 11:08

eztam


People also ask

Where is git bash path in Windows?

Go to File > Preferences > Settings and type shell in search settings. After that, navigate to Terminal > Integrated > Shell:Windows and update the path with Git Bash executable: C:\Program Files\Git\bin\bash.exe and save. Reopen VS Code terminal and it will prompt Git Bash.


2 Answers

Here are two ideas.

You can have your path with double quote mark.

export PATH=$PATH:"/C/Program Files (x86)/apache-maven-3.3.3/bin"

enter image description here

Or, You can also make symbolic link for the directory.

ln -s "/C/Program Files (x86)/apache-maven-3.3.3/bin" ./mvnbin
export PATH=$PATH:/your-path/mvnbin

enter image description here

It works for me in mingw32 environment.

like image 128
tommybee Avatar answered Oct 03 '22 23:10

tommybee


I needed to add something to my Git Bash path permanently each time I open it. It was Meld.exe path which can be added with:

export PATH=$PATH:"/C/Program Files (x86)/Meld/lib" 

In order to execute this command each bash session, you need a ~/.bashrc file. Check if it already exists or create it using notepad ~/.bashrc or touch ~/.bashrc.

You can check where it is with:

echo ~ 

Open it and add the command that adds the PATH (first command in this response).

I hope you found this useful.

like image 41
David L. Avatar answered Oct 04 '22 01:10

David L.