在Windows下扩展git bash中的$ PATH变量 [英] Extend $PATH variable in git bash under Windows
问题描述
我正在尝试通过将以下内容添加到文件〜/.bashrc中来扩展git bash(MinGW Shell)中的$ PATH变量
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'
这样做并重新启动bash之后,似乎像预期的那样扩展了$ PATH变量:
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
这里出了什么问题?如何正确扩展PATH变量?
What went wrong here? How do I extend the PATH variable correctly?
推荐答案
这里有两个想法.
您的路径可以带双引号.
You can have your path with double quote mark.
export PATH = $ PATH:"/C/程序文件(x86)/apache-maven-3.3.3/bin"
export PATH=$PATH:"/C/Program Files (x86)/apache-maven-3.3.3/bin"
或者,您也可以为目录建立符号链接.
Or, You can also make symbolic link for the directory.
ln -s"/C/程序文件(x86)/apache-maven-3.3.3/bin" ./mvnbin
导出PATH = $ PATH:/your-path/mvnbin
ln -s "/C/Program Files (x86)/apache-maven-3.3.3/bin" ./mvnbin
export PATH=$PATH:/your-path/mvnbin
它在mingw32环境中对我有用.
It works for me in mingw32 environment.
这篇关于在Windows下扩展git bash中的$ PATH变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!