Getting Pow to use RVM’s Ruby Version on Mavericks

2 minute read

After upgrading to OS X Mavericks 10.9 with relatively little friction, I decided to get back to work on a Rails site that needed some love. When developing Rails sites locally I use the excellent Pow server to serve up pages locally using a http://mysite.dev address without having to fire up a rails s. If you aren't using it, you should be.

I go to work on my site and lo-and-behold, I see the classic Pow error message:

Looks like Pow was using Ruby 2.0.0 and not the Ruby I had specified in the RVM .ruby-version and .ruby-gemset files, as is the specified way to do it on a project basis. I am not sure whether shifting from the old .rvmrc files to the new format, a clean installation of RVM, a clean installation of Pow, or the upgrade to Mavericks was the culprit, but fixing seemed pretty easy.

I created a /path/to/server/.powrc file to load the correct ruby version and gemset:

if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ]; then
  source "$rvm_path/scripts/rvm"
  if [ -f ".ruby-gemset" ]; then
    rvm use `cat .ruby-version`@`cat .ruby-gemset`
  else
    rvm use `cat .ruby-version`
  fi
fi

Then I ran touch $HOME/.pow/restart.txt and fired up the server. No go :/

It took me a little bit to figure out what was happening. In my setup I have most of my shell logic in ~/.bash_profile which is not loaded by Pow. Because of this, rvm use ... was failing silently in the .powrc file due to it not being a function (ie: not loaded yet).

The fix was simple now that I knew the source of the problem. The ~/.bash_profile file is not loaded by Pow, however, the ~/.bashrc is loaded. This means I just had to add the RVM loading line into that file too.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

A quick touch $HOME/.pow/restart.txt, browser reload and voila! Pow is working again :) Hope this helps get you back on track with Pow, RVM and Mavericks.

Lastly, I run a small software company called Urban Apps. It pays the bills so I can take the time to write helpful posts like this one. If you found this page helpful at all, I would really appreciate it if you would check out my iPhone/iPad Apps on the iTunes App Store.

Was this page helpful for you? Buy me a slice of 🍕 to say thanks!

Comments