25

I added something to my bash_profile while trying to add Playframework to my path and something got messed up badly.

I added the following line to my .bash_profile

export PATH=$PATH:the path to my play excitable 

then I saved everything and restarted my terminal. I can no longer do anything from my terminal. I can't cd into any directory, I can no longer find java, I can't open vi or nano. I found this thread on SuperUser that suggested opening a different terminal and changing the bash profile.

I tried opening bash by typing

/bin/bash

and I was successfully able to open another terminal but I still don't have access to any of the regular unix commands. I still wasn't able to open vi or nano to remove the line that is causing the problem.

I tried downloading a new terminal application without any luck.

I tried turning on hidden files so that I can just change the file with a text editor by running the following command:

defaults write com.apple.finder AppleShowAllFiles TRUE

but since my terminal isn't working that didn't work either.

How can I fix my computer.

Community
  • 1
  • 1
j.jerrod.taylor
  • 1,120
  • 1
  • 13
  • 33
  • @MarcB Can this be migrated to a different stackexchage site? – j.jerrod.taylor Jan 11 '14 at 20:44
  • Did you create ` .bash_profile` or was it pre-existing? Do you have a `.profile` file ? If so, merge them (use Finder). – damienfrancois Jan 11 '14 at 20:48
  • "Can't `cd`" sounds like you messed up more than you are telling us. But if it's just the `PATH` after all, you should be able to use a full path; `/usr/bin/vi` (or wherever is correct for your platform; `/bin/vi`? `/Applications/Visual Editor.app`?) – tripleee Jan 11 '14 at 20:50
  • @damienfrancois I tried that and it didn't seem to work. I took a screenshot of my terminal. [Here](http://i.imgur.com/8vKsUJY.png) is the picture. – j.jerrod.taylor Jan 11 '14 at 21:05
  • try `/usr/bin/vi ~/.bash_profile` as @trojanfoe suggests – damienfrancois Jan 11 '14 at 21:08
  • The duplicate https://stackoverflow.com/questions/29246238/error-message-on-terminal-launch has some less Mac-specific advice. – tripleee Jul 28 '20 at 05:50

1 Answers1

81

While this is offtopic for stackoverflow, it's also pretty simple to fix:

  1. Start Terminal.app.
  2. Reset $PATH:

    $ export PATH=/bin:/usr/bin:/usr/local/bin
    
  3. Fix ~/.bash_profile:

    $ vi ~/.bash_profile
    

Or you can avoid setting $PATH at all with:

$ /usr/bin/vi ~/.bash_profile
trojanfoe
  • 120,358
  • 21
  • 212
  • 242
  • 1
    @damienfrancois My solution is to set `$PATH` *temporarily*, just long enough to find `vi`. I am not suggesting what his final `$PATH` should be set to in `.bash_profile`. And `vi` is in `/usr/bin`. – trojanfoe Jan 11 '14 at 20:59
  • @trojanfoe `vi` is located in `/opt/usr/bin`. Please read my previous comments – damienfrancois Jan 11 '14 at 21:01
  • @damienfrancois, the `vi` you are suggesting is the macports version. it's presumed most people would use the one at `/usr/bin/vi` – l'L'l Jan 11 '14 at 21:01
  • I tried that and it didn't seem to work. I took a screenshot of my terminal. [Here](http://i.imgur.com/8vKsUJY.png) is a the picture. It is hosted on imgur. – j.jerrod.taylor Jan 11 '14 at 21:03
  • 1
    @trojanfoe I figured out what you meant. When you wrote "usr" I thought you were just using an abbreviation for username. I was using my actual username instead of the string "usr" I was able to open it. Thanks. – j.jerrod.taylor Jan 11 '14 at 21:12
  • 1
    @j.jerrod.taylor `usr` is not your username, it is the three letters `usr` as is. – damienfrancois Jan 11 '14 at 21:12
  • If you don't know how to edit your shell's startup files, chances are you also don't know how to exit `vi`, let alone use it for editing. The editor `nano` is obnoxious, too, but reportedly easier for beginners to cope with. Whether nano is installed by default obviously depends on your distro, but most of them seem to install it just because it has become the *de facto* standard for what to recommend to people who have no idea about editors. It is also installed by default on macOS (at least, I have it in `/usr/bin/nano`.) – tripleee Jul 28 '20 at 05:38