MacOS – How to undo “export PATH=’/usr/local/bin:$PATH’ >> ~/.bash_profile”

bashhomebrewmacospathterminal

I was trying to install homebrew, which wasn't working. It told me to do echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile. However this wasn't having any affect, and I thought maybe it was because of echo (I don't know any Bash), so I removed the Echo, ran brew doctor and it spat this out, which concerned me:

/usr/local/bin/brew: line 2: dirname: command not found
/usr/local/bin/brew: line 5: basename: command not found
/usr/local/bin/brew: line 8: readlink: command not found
/usr/local/bin/brew: line 16: cd: /Users/howard/../Library: No such file or directory
/usr/local/bin/brew: line 23: tr: command not found
/usr/local/bin/brew: line 23: uname: command not found
/usr/local/bin/brew: line 28: exec: ruby: not found

Is there any way to undo what I just did? Also, can someone please explain to me what I just did? I am never going to make the stupid mistake of copying and pasting commands I don't understand. I feel like a total moron right now.

I worry that I may have overriden /usr/bin/ with stuff? I can't run most of the basic commands like man, ls, and a few others. cd still works though. Is there any hope for me, or do I need to reinstall my OS?

Best Answer

You certainly don't need to reinstall - just remove the offending last line of the file and restart terminal to see the effects.

If you don't know how to edit the file from terminal, you can open the file in your system's default plain text editor:

/usr/bin/open ~/.bash_profile

Just delete the last line and save the file. (The >> tacks the output of the echo on to the end of the file) At that point, quit terminal, reopen terminal and test brew doctor again.

Apple has an overview of editors you can use in terminal if you want to edit files more regularly.

For beginners, the nano editor is perhaps the easiest since it has visible help for basic commands. You can get some more guided help on nano from the web by opening the URL in your preferred browser (or having terminal do that for you open http://www.nano-editor.org/).