Kategorien
Entwicklung

Using pow with rvm 1.19

Since rvm 1.19.0 there is a alternative way to specify a project related ruby version and gemset through the files .ruby-version and .ruby-gemset instead of the still valid use of the .rvmrc file. The .rvmrc is of course as before the default configuration for rvm, but it requires to be trusted, as it could contain any shell command. Further the recently supported files are compatible with other ruby version managers like rbenv or chruby.

So after an upgrade of rvm a message like below would be displayed if you enter a directory which contains a .rvmrc.

You are using ‚.rvmrc‘, it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to ‚.ruby-version‘ using ‚rvm rvmrc to [.]ruby-version‘
or ignore this warnings with ‚rvm rvmrc warning ignore /Users/dboeckma/workspace/mymine/bookmarks/.rvmrc‘,
‚.rvmrc‘ will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run ‚rvm rvmrc warning ignore all.rvmrcs‘.

Like the messages says you could switch to the new configuration with the given command.

rvm rvmrc to .ruby-version

This results in the following two files. First the .ruby-version in which the ruby version is defined.

ruby-2.0.0-p0

Second the .ruby-gemset with the gemset that should be used in conjunction with the ruby version.

octopress

Surely, the ruby version and gemset can differ in your files. 😀

So far so good. The problem comes with the next try to use pow with the new configuration files. The recommended .powrc, which comes with pow, only considers the .rvmrc file, which not exists any longer. As a result pow uses the wrong default system ruby version and gemset. With a slightly enhanced .powrc file, like the one below, it will run with both variations.

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

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

You can see the modifications also as gist on github.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.