Last Updated: February 25, 2016
·
11.08K
· aaronjensen

Using Pow with RVM's .ruby-version

There may very well be a better way to do this, but here is how I've set up my .powrc to read .ruby-version, a safer, more terse version of .rvmrc.

An example .ruby-version:

1.9.3-p327@my-gemset

In the project's .powrc:

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

3 Responses
Add your response

Recent versions of RVM will split out @my-gemset from .ruby-version into .ruby-gemset. Here's a modified version to account for it -

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

@calebwright is correct. And with distributed teams and non-standard development environments, it's not a great idea to fully commit one way or the other (fully ignoring .rvmrc files or assuming a .ruby-gemset, for example).

I put together a quick Gist at https://gist.github.com/nbibler/5307941 which describes a .powrc file you can put in your application directory that accounts for having a .rvmrc, .ruby-version, and optionally a .ruby-gemset files.

over 1 year ago ·
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
over 1 year ago ·