Matt Coneybeare

MC

Getting Pow to Use RVM's Ruby Version on Mavericks

| Comments

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:

Pow Problems

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:

1
2
3
4
5
6
7
8
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.

1
2
[[ -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 posting helpful at all, I would really appreciate it if you would check out my iPhone/iPad Apps on the iTunes App Store.

Comments

My name is Matt Coneybeare, I design and develop for iOS (iPhone, iPad and iPod Touch), Mac OS X and the Web out of New York. In 2008 I started a software company called Urban Apps that has made some pretty popular apps such as Ambiance and Hourly News. My current Stack Overflow reputation is about 27k.

I was a Rockstar a decade ago, but then went back to school and collected a Bachelor's Degree in Computer Science from U.C. Berkeley. Now I am settled down with my beautiful wife Di and our two doggies Hamachi and Foxy. While coding, I walk several miles/day on my Treadmill Desk. When not at my desk, I love exploring New York City as a Yelp Elite, or training for marathons.

Contact information

Name
Matt Coneybeare
Email
Website
Twitter
Instagram
GitHub
Google+
LinkedIn