7

I added some things to my .bash_profile on my Mac OS X and they give an error. Here is my entire log of text when I start a terminal now:

Last login: Thu Oct 25 23:10:03 on ttys000
dirname: illegal option -- b
usage: dirname path
-bash: /bin/naoqi-bin: No such file or directory
-bash: exec: /bin/naoqi-bin: cannot execute: No such file or directory

[Process completed]

The problem is that since "Process completed", I can't use terminal. How do I access .bash_profile (I can't find out how from the finder), or how do I run terminal normally again so I can get that out of the .bash_profile file?

tripleee
  • 175,061
  • 34
  • 275
  • 318
jay
  • 477
  • 1
  • 9
  • 17
  • Possible duplicate of [Error message on Terminal launch](http://stackoverflow.com/questions/29246238/error-message-on-terminal-launch) – tripleee Jun 14 '16 at 09:22
  • Does this answer your question? [How to restore .bash\_profile on a mac? None of my unix terminal are working](https://stackoverflow.com/questions/21067625/how-to-restore-bash-profile-on-a-mac-none-of-my-unix-terminal-are-working) – tripleee Jul 28 '20 at 05:30

4 Answers4

17

Open Terminal, and go to File (or Shell) -> New Command. Type in open -e .profile (or substitute some other file instead of .profile), and hit Run. That should open TextEdit with the file you want to fix; you can remove the offending lines there.

Community
  • 1
  • 1
nneonneo
  • 171,345
  • 36
  • 312
  • 383
7

For completeness, here's another way: open TextEdit (or your favorite GUI text editor). In the open dialog, press Command-Shift-Period, and it'll display (and let you open) invisible files such as .profile. Remove the offending lines, save, and you should be good to go.

Gordon Davisson
  • 118,432
  • 16
  • 123
  • 151
1

You can run Bash with all startup scripts disabled to get around problems with startup scripts: choose Shell > New Command and run bash --noprofile.

See the Bash man page for more information about the Bash command-line options and startup files: x-man-page://1/bash

Also note that you can lookup and view man pages in Terminal even when your shell isn't working, by clicking on the Help menu and entering a topic in the search field. Terminal will display matching man pages. Choose one from the Help menu to view it in a new window. You can also open an x-man-page: scheme URL from any application.

Chris Page
  • 18,263
  • 4
  • 39
  • 47
0

I could not open it with:

open ~/.bash_profile

But when I entered

sudo open ~/.bash_profile

It worked and I was able to open the file!

Aaron Lelevier
  • 19,850
  • 11
  • 76
  • 111
  • You absolutely should not need `sudo` to open your `.bash_profile` in the first place; it _needs_ to be owned by yourself. – tripleee Jul 28 '20 at 05:49