When ever I close and open Terminal.app, it never loads my ~/.bash_profile. I have my RVM setup at the top of the file but it never loads it.

As you can see, when I type rvm into Terminal, it says command not found this is a pain as I have to run source ~/.bash_login every time I open Terminal.

rvm command not found

Am I the only one with this problem? What am I doing wrong?

  • Out of curiosity, what does your Terminal preferences window, under the 'Startup' tab look like? – Jason Salaz Aug 16 '11 at 20:03
  • They show this: i.qyk.in/loD8A.png – Dean Perry Aug 16 '11 at 20:08
  • 1
    Strange, considering the bash man page: When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior. And that /usr/bin/login setting is self-explanatory... – Jason Salaz Aug 16 '11 at 20:55
  • 3
    "it never loads my ~/.bash_profile" "I have to run source ~/.bash_login" Which is it? Are you using ~/.bash_profile or ~/.bash_login? Only one of them will be run. – Chris Page Aug 19 '11 at 11:21

Does it have to be .bash_login? Try renaming it to .profile.

  • Or .bash_profile - which works – Rene Larsen Aug 14 '11 at 17:34
  • This is very surprising. ~/.bash_login should work just as well as ~/.bash_profile. It works for me. You can put an echo .bash_login at the start of ~/.bash_login to see whether it gets run. Of course, it won't be run if you also have ~/.bash_profile. – Chris Page Aug 19 '11 at 11:26

Bash only reads the .bash_login file if it's started as a login shell (was passed the --login flag). Try renaming it to .bashrc instead, which is evaluated when bash was invoked as an interactive shell without the --login flag.

  • I have tried .bashrc but it does the same – Dean Perry Aug 14 '11 at 17:29
  • 3
    Prior to Lion, Terminal creates login shells unless you provide a custom command in Preferences > Startup or Preferences > Settings > [profile] > Shell. As of Mac OS X Lion 10.7, Terminal always creates login shells, even for custom commands, if they're listed in /etc/shells. – Chris Page Aug 19 '11 at 11:15

Make sure your .bash_login script doesn't contain relative paths like

source .profile

Change to

source ~/.profile

Lion changes the directory to your current tab or where your last session is, so all paths have to be absolute now.


For me bash in Lion does not load ~/.profile either.

Adding source ~/.profile command to run at startup in shell preferences helped, but is quite unelegant.

  • Check your preferences to ensure you haven’t done something to suppress the creation of a login shell. Is anything in Terminal > Preferences > Settings > [profile] > Shell > Startup or Terminal > Preferences > Startup > Shells open with customized? – Chris Page Mar 10 '12 at 23:06

Changing .bashrc from

source .bash_profile


source ~/.bash_profile

did the trick for me.

  • 2
    I recommend going the other direction: Have ~/.bash_profile source ~/.bashrc. Put all the stuff you want to be common to login and non-login shells into ~/.bashrc. ~/.bash_profile should only contain configuration commands for login shells. – Chris Page Sep 8 '11 at 11:55

The default behavior on my MacBook running Sierra (I don't know about High Sierra) seems to be that Terminal will run .bash_profile on login.

Only if .bash_profile does not exist will Terminal go and run .bash_login instead.

Check to make sure that you do not have an empty .bash_profile sitting around in your home directory. If you do, delete it and re-login; then you should see Terminal running your .bash_login.

(Empirically: my MacBook does not open or run either .profile or .bashrc. But indeed, I can disable my .bash_login by running touch ~/.bash_profile, and restore it to working order by running rm ~/.bash_profile.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .