The Weirdness of Ruby Version in Debian Wheezy

Due to certain application dependency on Ruby, I need to install Ruby on the machine. As you can see from below, the versioning and packing in Debian puzzled me.

Install the latest Ruby version and the ruby-switch program which will can set the default Ruby version to any installed version.
$ sudo apt-get install ruby1.9.3 ruby-switch

Check our just installed version.
$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

Show the list of available version. Note that listing shows ruby1.9. I thought we've just installed version 1.9.3?
$ sudo ruby-switch --list

Set version 1.9.3 as our default Ruby version.
$ sudo ruby-switch --set ruby1.9.1

Check the binary of ruby. Apparently it is a soft link.
$ file `which ruby`
/usr/bin/ruby: symbolic link to `/etc/alternatives/ruby'

Again, another soft link but pointed to ruby1.9.1.
$ file /etc/alternatives/ruby
/etc/alternatives/ruby: symbolic link to `/usr/bin/ruby1.9.1'

Check whether /usr/bin/ruby1.9.1 is a binary or soft link. As result shown, it's a binary program.
$ file /usr/bin/ruby1.9.1
/usr/bin/ruby1.9.1: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xf5d1e1e2959315b9d4907b6a40fb2c44f1c27c87, stripped

Check the ruby1.9.1 version again. What?! Why it's showing version 1.9.3?
$ /usr/bin/ruby1.9.1 --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

Check which package contains this /usr/bin/ruby1.9.1 binary. Weird, it belongs to ruby1.9.1 package, which is reasonable but I didn't install that.
$ apt-file search /usr/bin/ruby1.9.1
ruby1.9.1: /usr/bin/ruby1.9.1

Show the reverse dependancies. Why ruby1.9.1 needs ruby1.9.3?
$ apt-cache rdepends ruby1.9.1 | grep ruby

Okay. Let's check with Ruby Gem. Similar steps.
$ file `which gem`
/usr/bin/gem: symbolic link to `/etc/alternatives/gem'

$ file /etc/alternatives/gem
/etc/alternatives/gem: symbolic link to `/usr/bin/gem1.9.1'

Interesting. gem1.9.1 is a ruby script.
$ file /usr/bin/gem1.9.1
/usr/bin/gem1.9.1: Ruby script, ASCII text executable

However, when checking the version of /usr/bin/gem1.9.1.
$ /usr/bin/gem1.9.1 --version

What the heck?!

No comments:

Post a Comment