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.

Kategorien
Entwicklung

Hello Ruby! Hello Ruby on Rails!

Recently I took a closer look at Ruby and Ruby on Rails. Therefore I searched the web for some usefuly documentation to get a quick start. Here are the results.

Programming Ruby – The Pragmatic Programmer’s Guide is a free book about Ruby linked on the Ruby documentation page. Quite old but for most properties of the language suitable. Of course, there are some more useful links on the Ruby documentation page like the Ruby Core Reference or the Ruby Standard Library Reference, which lead to the Ruby documentation project.

O’Reilly has two free german books available on the internet. The first is O’Reilly Praxiswissen Ruby about the language Ruby and the second is O’Reilly Praxiswissen Ruby On Rails about Ruby on Rails. The last is mainly about Ruby on Rails 2 and for starters highly likely not interesting since Ruby on Rails 3 was released.

Ruby on Rails Tutorial is a great book about Ruby on Rails 3, which is free available on the internet. It is also purchasable as printed version or as pdf version on the site. In the book you will create a twitter simliar page by a test driven approach and with source code management by git. A short introduction to Ruby is certainly present in the book. On the side of Ruby on Rails can be found also some useful stuff. Two of them are the Ruby on Rails documentation and the Ruby on Rails tutorials.

Lastly some more links: