2

In order to use rvm (https://rvm.beginrescueend.com/), I need to run

source ~/.bash_profile

each time when I start a new shell. How do I automatically do this when I start my computer, rather than having to type it each time?

This is my .bash_profile:

 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
 # Load RVM into a shell session *as a fu    nction*
 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 
 # Load RVM function
2

A few options here:

  1. Put the contents of your .bash_profile in ~/.bashrc.
  2. Add source ~/.bash_profile to ~/.bashrc.
  3. Add [ -e ~/.bash_profile ] && source ~/.bash_profile to your /etc/bashrc
  4. If you are switching users (e.g. with sudo or su), specify that you want a login environment to be loaded (e.g. with su - instead of just su).

Background: .bash_profile is specific to login shells, whereas .bashrc is loaded by all shells. So you're either missing the logic that causes .bash_profile to be loaded in the first place, or you're not launching a login shell when you're launching your shell.

  • thanks! it works! "Add source ~/.bash_profile to ~/.bashrc." – larry May 12 '11 at 3:41
1

At the end of my .bash_profile I have this line:

source ~/.rvm/scripts/rvm

I tried using what you have in your bash profile (which is part of the instructions for setting up rvm) but I could never get it to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.