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
BMDan
  • 7,249
  • 2
  • 23
  • 34
larry
  • 4,037
  • 9
  • 36
  • 42

2 Answers2

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.

BMDan
  • 7,249
  • 2
  • 23
  • 34
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.

tfitzgerald
  • 443
  • 3
  • 6