英文:
MacOS source ~/.bash_profile disabled everything
问题
所以我试图在我的Mac上设置Go编程环境,并通过相应地修改.bash_profile将必要的目录添加到路径中。保存.bash_profile后,我尝试运行"go version",但仍然无法正常工作。
经过一番搜索,我发现如果我执行以下操作:
source ~/.bash_profile
go版本将正常工作。但是似乎我的PATH已经改变,因为像nano、vi、ls、sudo等命令不再起作用。
有没有办法恢复我的初始环境PATH?
提前感谢!
PS-如果我的问题不清楚,请告诉我。
英文:
So I was trying to setup the Go programming environment on my Mac and add the necessary directory to the path by modifying the .bash_profile accordingly. After saving the .bash_profile, I tried running "go version" for example but it still didn't work.
After a bit of searching I found that if i did the following:
source ~/.bash_profile
The go version would work. Which it does but it seems that my PATH has been changed since commands such as: nano, vi, ls, sudo etc do not work anymore.
Is there a way of recuperating my initial environment PATH?
Thanks in advance!!
PS - let me know if my issue is not clear
答案1
得分: 1
请注意,对于您当前的shell会话,您的路径可能只是“损坏”的:Mac OS X并不严格使用.bash_profile来设置您的PATH。
我猜测您没有正确地写出export PATH=$PATH:$GOPATH/bin
和export GOPATH=/Users/sSmacKk/go/
(或者您想要设置的任何其他位置):如果您忘记将现有路径分配回新路径,您将会遇到问题。
- 从
/usr/libexec/path_helper
中运行path_helper
(通常会在您的路径上!) - 添加以下行:
export GOPATH=/wherever/you/want/
,然后是export PATH=$PATH:$GOPATH/bin
到您的.bash_profile
文件中 - 保存并退出文本编辑器,然后运行
source .bash_profile
。
英文:
Note that your path is likely just "broken" for your current shell session: Mac OS X doesn't strictly use .bash_profile for your PATH.
My guess is that you didn't write out export PATH=$PATH:$GOPATH/bin
and export GOPATH=/Users/sSmacKk/go/
(or wherever you wanted to set it) correctly: if you forget to assign the existing path back to your new path, you'll have problems.
- Run
path_helper
from/usr/libexec/path_helper
(which would normally be on your path!) - Add the lines:
export GOPATH=/wherever/you/want/
and thenexport PATH=$PATH:$GOPATH/bin
to your.bash_profile
- Save and exit from your text editor and then
source .bash_profile
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论