pkj39a
Last Updated: February 25, 2016
·
10.33K
· aaronjensen
Cd93483c1bb616efb5480b639dbb9ca3

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
Say Thanks
Respond

3 Responses
Add your response

4936

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 ·
5339
Cfaf1fb96eb0b184e3134d62c45fe8d3

@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 ·
5380
D6775ad7ff29324eef331af7a1d5667d
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 ·