I'm a programmer specialising in performant and scalable systems using PHP and Ruby and cooking

On Ruby | Rail | RVM | Pow

Using RVM with Pow

Pow is a great little tool for rapidly developing Ruby on Rails applications on OSX. Pow take away the headache of managing development services by allowing you access to your projects from a local subdomain.

This allows you to have multiple projects running at once without needing to use different port numbers and removes the headache of setting up a proxy server such as Nginx or Apache.

As a bonus; using Pow also enables quick and simple sharing of your applications over your local network, something which is great for those wokring in teams.

Most of the documentation for Pow is on the http://pow.cx/ however the instructions for working with RVM are a little lacking.

In most cases you'll want to using seperate gemsets for your projects and such you'll want Pow to also use these gemsets to run each application.

Go ahead and install Pow whilst we prepare for running your application.

When booting your application Pow will check for 2 files in order to manage it's per application environment .powrc and .powenv, loaded in that order.

We're going to be dealing with the .powrc and going to be adding a small script to load RVM:

if [ -f "${rvm_path}/scripts/rvm" ]; then  
  source "${rvm_path}/scripts/rvm"

  if [ -f ".rvmrc" ]; then
    source ".rvmrc"
  elif [ -f ".ruby-version" ] && [ -f ".ruby-gemset" ]; then
    rvm use `cat .ruby-version`@`cat .ruby-gemset`
  elif [ -f ".ruby-version"  ]; then
    rvm use `cat .ruby-version`


As you can see it requires the creation of .ruby-version and .ruby-gemset files which now replace the .rvmrc.

In my example application I have:

# .ruby-version

this tells RVM to use Ruby version 2.1.0

# .ruby-gemset

this tells RVM to use the gemset "example_app"

Now link your app as described in the docs. Assuming you have all your required gems installed in that gemset your app will now be accessible in the browser, in my case http://example-app.dev/.

Making updates

If you update your environment you will need to tell Pow to restart:

touch tmp/restart.txt  

run this in your application directory