I have been using RVM for several years - straight in the terminal and
in a bash shell in emacs. But all of a sudden I started having path
problems. I don’t remember having updated my RVM version, though I
quite possibly I did before I updated my installed rubies for the
latest security patches. Or perhaps there is some odd interaction with
the ruby that got installed when I installed the Heroku toolbelt (v
3.2.0) this last week; it appears to have installed it’s own ruby in
/usr/local/heroku/ruby/bin/ruby but then added /usr/local/heroku/bin
with export PATH="/usr/local/heroku/bin:$PATH"
in my .bashrc.
The symptom was that in my bash shell within emacs I was getting
warnings about RVM not finding what it expected at the start of my
path. I should have copied the error message but it was expecting
something like /Users/cnk/.rvm/gems/ruby-2.0.0-p353/bin
. Initially I
was getting a path starting with /usr/local/heroku/bin
because the
Heroku Toolbelt install had placed that line at the end of my .bashrc
file. But even after having moved the heroku line into my .profile
before the rvm line, I was still getting oddities when trying to use
knive (installed with the chef gem). I tried the fixed suggested in
the warning message: rvm get stable --auto-dotfiles
. That gave me
version 1.25.14. and made modifications to my dotfiles:
That made everything work in the terminal but made it much worse in
emacs. With the default rvm setup (source "$HOME/.rvm/scripts/rvm"
in
my .bash_profile file), rvm was not getting loaded in my emacs
shell. type -t rvm
was returning ‘file’ instead of ‘function’ and
none of my rvm commands would work - no rvm use
or rvm gemset
list
. I fooled around for a bit and sorted out that what I need to
get rvm to work in the terminal AND in my emacs shell is to have this
line in my .bashrc
file NOT in .bash_profile or .profile:
That works fine and does not seem to have any problems even if I create a new shell within an old one.
Other RVM and Emacs Options
There are a couple of more sophisticated ways of using rvm within emacs that I came across while trying to figure out why this had suddenly stopped working. One of these days I should look at them:
- Emacs 24 Rails Development Environment - From scratch to Productive in 5 Minutes
- rvm.el - and the resources listed in the README such as Avdi Grimm’s Emacs Reboot series
Path Warnings Redux
I got the same warning again today - when changing directories from within a shell running in emacs:
This time a) I remembered to record it and b) I read the full message!
I went with the last option: rvm use ruby-2.0.0-p353
. Running that
command got me the same warning again - but once the command executed,
then all was repaired and the rest of the commands work fine, e.g. rvm
list, rvm gemset list, etc.