Extend $PATH variable in git bash under Windows

eztam picture eztam · Aug 31, 2017 · Viewed 42.2k times · Source

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?

Answer

tommybee picture tommybee · Aug 31, 2017

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.