Running Rbenv and Pythonbrew Side by Side

Today, I went into a problem running pythonbrew after installing ruby using rbenv for setting up this blog last week. It took me awhile to figure out that rbenv was the problem. ~/.bashrc and ~/.profile were the only shell initialization files before rbenv came into the picture.

~/.profile
1
2
3
4
5
6
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

When installing rbenv, ~/.bash_profile is created to point to the path ~/.rbenv where ruby is installed.

~/.bash_profile
1
2
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Later I found out that if ~/.bash_profile exist, files ~/.bash_login and ~/.profile will not be included.

Only one of the files below will be included in the following order.

  1. .bash_profile
  2. .bash_login
  3. .profile

Including ~/.bashrc in ~/.bash_profile resolved the issue.

~/.bash_profile
1
2
3
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
[ -r ~/.bashrc ] && source ~/.bashrc