MacOS source ~/.bash_profile 禁用了所有内容。

huangapple go评论84阅读模式
英文:

MacOS source ~/.bash_profile disabled everything

问题

所以我试图在我的Mac上设置Go编程环境,并通过相应地修改.bash_profile将必要的目录添加到路径中。保存.bash_profile后,我尝试运行"go version",但仍然无法正常工作。

经过一番搜索,我发现如果我执行以下操作:
source ~/.bash_profile

go版本将正常工作。但是似乎我的PATH已经改变,因为像nano、vi、ls、sudo等命令不再起作用。

有没有办法恢复我的初始环境PATH?

提前感谢!
MacOS source ~/.bash_profile 禁用了所有内容。

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!!
MacOS source ~/.bash_profile 禁用了所有内容。

PS - let me know if my issue is not clear

答案1

得分: 1

请注意,对于您当前的shell会话,您的路径可能只是“损坏”的:Mac OS X并不严格使用.bash_profile来设置您的PATH。

我猜测您没有正确地写出export PATH=$PATH:$GOPATH/binexport GOPATH=/Users/sSmacKk/go/(或者您想要设置的任何其他位置):如果您忘记将现有路径分配回新路径,您将会遇到问题。

  1. /usr/libexec/path_helper中运行path_helper(通常会在您的路径上!)
  2. 添加以下行:export GOPATH=/wherever/you/want/,然后是export PATH=$PATH:$GOPATH/bin到您的.bash_profile文件中
  3. 保存并退出文本编辑器,然后运行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.

  1. Run path_helper from /usr/libexec/path_helper (which would normally be on your path!)
  2. Add the lines: export GOPATH=/wherever/you/want/ and then export PATH=$PATH:$GOPATH/bin to your .bash_profile
  3. Save and exit from your text editor and then source .bash_profile.

huangapple
  • 本文由 发表于 2013年11月12日 07:55:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/19918376.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定