In this post I would like to show what openSUSE has to offer to ruby enthusiasts.
The latest openSUSE version ships with ruby 1.8.7, rubygems 1.3.1 and rails 2.3.2. The latest two being not so recent, here is where the openSUSE project shines. Say hello to devel:languages:ruby and devel:languages:ruby:extensions build service projects.
The first is a project containing a more recent 1.8.7 ruby (p249 vs p72 in 11.2). However, as a build service project, it is built on top of multiple targets so you can add this repository not only to 11.2 but also to SLE and older openSUSE releases.
In this project you will also find a ruby19 package which is nothing else than ruby 1.9.1 p376 installable in parallel with 1.8.7.
The devel:languages:ruby:extensions contains ruby libraries and gems. For example you can find rails 2.3.5 there. Libraries are usually packaged as ruby-something and gems are packaged as rubygem-something. Gem packages have some nice attributes:
To add the gem repository to your 11.2 system, just do (as root):
zypper ar http://download.opensuse.org/repositories/devel:/languages:/ruby:/extensions/openSUSE_11.2 rubygems
While the ruby environment provided by openSUSE is great, you may want to go one step further. What comes to my head:
rvm is a nice tool that can quickly compile ruby interpreters from source and switch between them, all without root access (you can also set the current interpreter to the “system” one). Gems you install for one interpreter are isolated from the other interpreters, and you can create “gem sets”.
While rvm can be installed really easily:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
for the HEAD version in github or
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-latest )
You can also install it the “openSUSE way”, if you added the devel:languages:ruby:extensions repository:
zypper install rubygem-rvm
Once you have it installed, you will need to run rvm-install (as user) and edit your shell profile so that the environment is set correctly.
Then you can start using it. To see all the interpreters available in your system:
To see all the ones known to rvm:
rvm list --all
Build 1.9 from source:
rvm install ruby-1.9.2-head
rvm install jruby
rvm use jruby
Then you can “double check”:
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [amd64-java]
Of all the new ruby tools, the ones I find most useful is the bundler, which was created as a rails independent solution to make ruby applications specify the gems they need in their environment.
You can create a Gemfile in the top level directory of your application:
source 'http://gemcutter.org' gem "rails", "3.0.0.beta3" gem "runt", :git => "http://github.com/tevio/runt.git"
As you can see, you can specify gems from git repositories, or use specific branches or versions. This is really nice for deployment, as you can get the working environment really easy.
Would install the missing gems. It would reuse system gems, etc. If you are using rvm, it would install them in the interpreter specific gems.
The bundler has more advanced features, like the ability to take all the gems and “bundle” them directly “in” the application, but I leave that as an exercise to the reader.
So that finishes this post. I hope you could see how openSUSE looks like for a ruby developer.
I would like to first thanks Marcus Rückert (a.k.a darix) as he was the main brain behind the rubygem packages. Also big thanks to the YaST, Klaus, SUSE Studio and Build Service teams, whose development resulted in many package updates and contributions.