OS X Terminal not recognizing any commands [duplicate]

I recently tried to install CoffeeScript on my mac and now am unable to use even the most basic of commands like ls, cd and so on. Something tells me that it's because the $PATH variable has changed. I remember having to do that when I tried to make the installation. I tried following the instructions found here, but it doesn't work because the vi command isn't found.

Upon entering echo $PATH in the terminal, it reads /usr/local/bin:


You corrupted your PATH variable definition. Without any indication of which method you choosed to modify it, I will make the hypothesis that you modified it within your ~/.bash_profile.

To recover from this situation, you will have to come back to a working shell environment and then try to fix correctly and test your ~/.bash_profile.

Recovery of a working ~/.bash_profile: none

Remove your ~/.bash_profile and create a backup of it. Since your PATH is not trustable, don't use it (use the full path of mv):

/bin/mv ~/.bash_profile ~/.bash_profile.bak

Open a new Terminal window, within this one, every command should be found. Check that you recovered a working PATH:

echo $PATH

If you find it easier, after this check, you could restart your session so that any new shell will get a working PATH.

Analyze what is wrong in your ~/.bash_profile

grep PATH ~/.bash_profile.bak

Fix and test it

Rather to fall back again with an unfunctionnal PATH, use the backup file of your ~/.bash_profile to fix it there it and test it.

To test it enter: . ~/.bash_profile.bak echo $PATH

Put back in place the validated /.bash_profile

Once you are satisfied, and you checked you have access to all your commands:

mv ~/.bash_profile.bak ~/.bash_profile

and if you want to use it immediatly without restarting your full session, just enter:

. ~/.bash_profile

To reset your path, remove the line that sets the path from your ~/.bash_profile or equivalent, then reopen your Terminal.

Edit it with /usr/bin/nano, or /usr/bin/open, or TextMate, or any other text editor. It's not that no command can be reached, but that the PATH doesn't include these binaries—they can still be manually opened by providing the path or using cd to the directory.