This problem has troubled me a lot before I found the solution to it. And no forum provided the right solution for it, hence this post. You can go through the rvm issue thread for more details about the issue.
Why this occurs?
This problem occurs when you have multiple active rvm sessions in the same terminal.
Solution
Simple solution to this problem is update your rvm version such that this pull request is present in that version or just point your rvm to the latest head. Run the below command and it will solve your problem.
rvm get head
Other potential solutions which might or might not work
create ~/.direnvrc
with the below content
# Circumvent https://github.com/direnv/direnv/issues/210
#
shell_session_update() { :; }
get stable
rvm get stable
Initialize rvm only once
If you have below line in multiple files like ~/.profile
or ~/.bash_profile
or ~/.bashrc
, please keep this line in only one of the files so that it gets initialized only once.
source $HOME/.rvm/scripts/rvm
export PATH="$PATH:$HOME/.rvm/bin
or
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH="$PATH:$HOME/.rvm/bin"