[英]How to add /usr/local/bin in $PATH on Mac
When I do 'open .profile' in the terminal I have the following:当我在终端中“打开 .profile”时,我有以下内容:
export PATH=$PATH:/usr/local/git/bin
Now I installed node.js for Mac and it says,现在我为 Mac 安装了 node.js,它说,
Make sure that /usr/local/bin is in your $PATH.
确保 /usr/local/bin 在您的 $PATH 中。
How can I add /usr/local/bin
to export PATH=$PATH:/usr/local/git/bin
?如何添加
/usr/local/bin
以导出PATH=$PATH:/usr/local/git/bin
?
This works in either bash (which is the default shell pre-Catalina) or zsh (which is the default shell from Catalina onward):这适用于 bash(这是 Catalina 之前的默认 shell)或 zsh(这是 Catalina 以后的默认 shell):
export PATH=$PATH:/usr/local/git/bin:/usr/local/bin
In zsh you can also do this for the same result:在 zsh 中,您也可以为相同的结果执行此操作:
path+=(/usr/local/git/bin /usr/local/bin)
尝试将 $PATH 放在最后。
export PATH=/usr/local/git/bin:/usr/local/bin:$PATH
To make the edited value of path persists in the next sessions使路径的编辑值在下一个会话中保持不变
cd ~/
touch .bash_profile
open .bash_profile
That will open the .bash_profile in editor, write inside the following after adding what you want to the path separating each value by column.这将在编辑器中打开 .bash_profile ,在将您想要的内容添加到按列分隔每个值的路径后,在以下内容中写入。
export PATH=$PATH:/usr/local/git/bin:/usr/local/bin:
Save, exit, restart your terminal and enjoy保存,退出,重新启动您的终端并享受
I've had the same problem with you.我和你有同样的问题。
cd to ../etc/ then use ls to make sure your "paths" file is in , vim paths, add "/usr/local/bin" at the end of the file. cd 到 ../etc/ 然后使用 ls 确保你的“路径”文件在 vim 路径中,在文件末尾添加“/usr/local/bin”。
I tend to find this neat我倾向于觉得这很整洁
sudo mkdir -p /etc/paths.d # was optional in my case
echo /usr/local/git/bin | sudo tee /etc/paths.d/mypath1
In MAC OS Catalina, this are the steps that worked for me, all the above solutions did help but didn't solve my problem.在 MAC OS Catalina 中,这是对我有用的步骤,上述所有解决方案确实有帮助,但没有解决我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.