0

When I start terminal up on mac I am getting this error:

-bash: user@computer:$: command not found

What does it mean?

I ran the following in terminal to diagnose the issue:

echo $PS1
\h:\W \u\$
Jeremy Lynch
  • 6,780
  • 3
  • 52
  • 63
  • What happens after that error message appears? Do you get another command prompt (`user@computer$`)? Does the Terminal window close immediately? If you do have another prompt, try typing `echo $PS1` and include the result in your question. Also, have you edited any of these files in your home directory: `.profile`, `.bash_profile`, `.bashrc`? You may have told your shell (`bash`) to run a non-existent command when it starts up. – dg99 Nov 21 '13 at 05:55
  • I installed rvm using 'sudo', and I that made some changes to my home directory, it did make some changes to the '.profile' file that I had to comment out. The Terminal window does not immediately close, and functions normally. There just is this normal error on startup – Jeremy Lynch Nov 21 '13 at 05:59
  • So the error does not appear after every prompt, but only for the first prompt you see in a shell? That suggests the problem is in your `.profile` (maybe you missed something that `rvm` changed) *or* perhaps in your system's `/etc/profile` or `/etc/bashrc`. If you installed using `sudo`, it may very well have changed some of the system-wide shell startup files. :( – dg99 Nov 21 '13 at 06:05
  • 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 12 '22 at 06:04

1 Answers1

0

To determine that this is a startup file issue, try changing the shell to something other than bash.

ZSH is included with macOS. To change the shell to ZSH run:

chsh -s /bin/zsh

You will be prompted for your user password, once complete press ⌘N to open a new terminal window, you will see a slightly different prompt.

If the error does not occur, then there is an issue in one of the bash startup files. Switch back over to bash with chsh -s /bin/bash and double check your ~/.bashrc, ~/.profile, and ~/.bash_profile, as well as /etc/bashrc and /etc/profile.

If bash remains broken for you, using ZSH over Bash is always an option.

Aaron Sutton
  • 179
  • 1
  • 7