开发者

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 defini开发者_开发知识库tely 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?


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜