Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the deal with rubygems on Debian? It's different and strange

I've noticed at least the following oddities around rubygems on Debian (5.0 lenny in my case):

  • Packages go into a different installation location: /var/lib/gems vs /usr/lib/ruby/gems
  • The debian package is rubygems 1.3.6, and updating rubygems to the latest version (1.3.7) doesn't work:
  $ sudo gem update --system
  ERROR:  While executing gem ... (RuntimeError)
    gem update --system is disabled on Debian. RubyGems can be updated using the official Debian repositories by aptitude or apt-get.
  • Not all gems appear to work like they do on other systems. For instance, when installing Phusion Passenger, it did not detect the "rack" gem even though it was definitely installed.
  • Manually installing rubygems using the source tarball and reinstalling all my gems (to /usr/lib/ruby/gems) made my problems go away.

What's the deal? Why is debian's package different?

like image 243
Yetanotherjosh Avatar asked May 17 '10 05:05

Yetanotherjosh


People also ask

What is RubyGems Linux?

RubyGems is a system for managing Ruby software libraries. Ruby code packaged in this manner is called a gem. When you find Ruby software you want to use in a project, gems offer a means of downloading, installing and managing the software. History.

What is RubyGems used for?

The RubyGems software allows you to easily download, install, and use ruby software packages on your system. The software package is called a “gem” which contains a packaged Ruby application or library. Gems can be used to extend or modify functionality in Ruby applications.

Does RubyGems come with Ruby?

Ruby comes with RubyGems by default since version 1.9, previous Ruby versions require RubyGems to be installed by hand.


3 Answers

Note that what I wrote below has significantly changed recently. The Debian Ruby Team has more or less completely revamped their entire approach, including but not limited to their packaging of RubyGems. I'm not sure about Debian 6, but in the version after that, installing Ruby and the RubyGems package from Debian should be safe, maybe even recommended. And obviously, that is going to trickle down into Ubuntu as well.


[EDIT: The following is outdated as of Debian 7 at the latest.]

Mixing to two different package managers is generally a very bad idea. The Debian-Ruby team tries their best to patch RubyGems in such a way that it becomes a slightly less bad idea.

Also, Debian has a set of rules that are intended to keep the system consistent. RubyGems also has its own set of rules. Those two sets of rules are unfortunately not compatible. So, the Debian-Ruby developers patch RubyGems to respect Debian's rules instead of RubyGems's. Moving gems from /usr/lib/ruby to /var/lib is one of those things.

Another problem is that Debian stable is, well, stable. This means that the Debian team guarantees that the behavior of the entire system, all 20000 packages, will never change during a release. But the RubyGems developers don't make their bugfixes available separately, the only way to get a bugfix is to upgrade to a new version, with (potentially) different behavior. Therefore, the Debian-Ruby developers cannot just take the RubyGems sources unmodified, they have to reverse engineer the bugfixes from 1.3.7 and apply them to their version of 1.3.6, to ensure backwards compatibility.

In general, you should avoid mixing package managers. Either use RubyGems for everything (in which case it is best to install RubyGems from source instead of using the Debian package) or use APT for everything, in which case you might be interested in DebGem, a service by the Phusion guys (makers of Ruby Enterprise Edition and Phusion Passenger) which provides Debian and Ubuntu packages for pretty much all Gems.

like image 118
Jörg W Mittag Avatar answered Oct 23 '22 15:10

Jörg W Mittag


If you like to manage yourself your ruby environment, I can take a look at RVM. It is a good way to have different environments catching your dev needs, because it's wiser to let the debian packages manage the global ruby env.

like image 20
Cédric Darné Avatar answered Oct 23 '22 15:10

Cédric Darné


The best way to avoid it being different and strange is to install it from source. (Many people recommend doing this in any case.)

For 1.9.2 onwards it's really very easy to install Ruby from source. That gets you Gem and everything else, automatically, and completely integrated. (For example, with the Rails gem installed, you can type 'ri field_for' to learn all about nested forms in Rails.)

With or without RVM, it's now the simplest and most reliable way to get Ruby. My 10c, anyway.

like image 30
Andy Avatar answered Oct 23 '22 15:10

Andy