bash 无法在 Mac OS X Yosemite 上修改 $PATH

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26059626/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 11:25:08  来源:igfitidea点击:

Not able to modify $PATH on Mac OS X Yosemite

macosbash

提问by Sithys

i just want to start with developing Android Apps on my new mac. Therefore i have to add platform-tools and tools from the Eclipsebundle to my $PATH.

我只想开始在我的新 Mac 上开发 Android 应用程序。因此,我必须将 Eclipsebundle 中的平台工具和工具添加到我的 $PATH。

The first thing i did was to add these two folders on my local Administrator-Account which worked fine with the command:

我做的第一件事是在我的本地管理员帐户中添加这两个文件夹,它可以很好地使用以下命令:

echo 'export PATH=/Users/myname/Desktop/adtbundle/sdk/platform-tools:"$PATH"' >> ~/.profile
echo 'export PATH=/Users/myname/Desktop/adtbundle/sdk/tools:"$PATH"' >> ~/.profile

So, then i added the MacMini into our Company-Domain and logged in with my Account which is saved in our active directory.

所以,然后我将 MacMini 添加到我们的公司域中并使用我的帐户登录,该帐户保存在我们的活动目录中。

I opened up the Terminal again and typed the two commands, but after that, while i want to verify my new $PATH (echo $PATH), my $PATH didn't change. Just the standard folders are in it.

我再次打开终端并输入两个命令,但在那之后,虽然我想验证我的新 $PATH ( echo $PATH),但我的 $PATH 没有改变。只有标准文件夹在里面。

I looked for another How-To to edit the $PATH and tryed it like this:

我寻找了另一个操作方法来编辑 $PATH 并像这样尝试:

cd

nano .bash_profile

in my .bash_profile i added:

在我的 .bash_profile 中,我添加了:

export PATH="/Users/myname/Desktop/adtbundle/sdk/platform-tools:$PATH"
export PATH="/Users/myname/Desktop/adtbundle/sdk/tools:$PATH"

saved all with control + oconfirmed the name by pressing returnand then exit nano by clicking control + x

保存所有并control + o通过按确认名称return然后单击退出nanocontrol + x

tryed to verify my new $PATH -> it did not change and my bash_profile is empty again - can someone tell me, what i did wrong?

试图验证我的新 $PATH -> 它没有改变并且我的 bash_profile 再次为空 - 有人能告诉我,我做错了什么吗?

THIS WORKED FOR MEhttp://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/

这对我有用http://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/

采纳答案by sanjeev.praja

After you add path to .bash_profile quit the terminal and open it again. the try to echo $PATH. It worked for me. else you can add path to /etc/profile.

将路径添加到 .bash_profile 后,退出终端并再次打开它。尝试回显 $PATH。它对我有用。否则,您可以将路径添加到 /etc/profile。

回答by daxeh

After editing .bash_profile, refresh the bash enviroment by restarting Terminal or typing the following command:

编辑 .bash_profile 后,通过重新启动终端或键入以下命令来刷新 bash 环境:

source ~/.bash_profile

'source' command will execute the contents of the argument supplied.

' source' 命令将执行提供的参数的内容。