MacOS源〜/ .bash_profile禁用了所有功能

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!! :D

PS - let me know if my issue is not clear

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.