Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
thanks! it works! "Add source ~/.bash_profile to ~/.bashrc." –  larry May 12 '11 at 3:41

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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