RubyGem-based Rails Plugins

Posted 2006-11-29…

One thing about Rails that’s a bit annoying to those of us who have been using Ruby for a long time is the lack of support for RubyGem-based plugins.

You have to take into account the kind of torture conversations like this were, for years upon years, and the kind of psychological damage it did to all of us:

What’s Ruby’s CPAN?

Anything like CPAN for Ruby?

What’s the package/library manager for Ruby?

Ruby sucks! Where’s CPAN?

Every time someone new ran into Ruby (often from Perl, especially in the beginning), it would inevitably come up— and someone would respond (out of ignorance or some type of masochistic delight), and it would ping-pong back and forth for a few days. It was the Ruby mailing list equivalent of Groundhog Day … but less fun. It was painfully repetitive, annoyingly pertinent, and frankly, a bit embarassing (how long it went on, at least). Thankfully, a group of great developers put together RubyGems out of the blue, and it caught on (beating back a bully or two in the process). RubyGems is a complete success— that’s obvious from the tremendous download stats— and the fact we don’t have those annoying CPAN conversations anymore.

Don’t get me wrong.. script/plugin install is great; it’s been wonderful. It’s fast, it’s easy, and it’s a large part of why Rails development is so compelling— the community is involved … plus, it just works. But let’s keep in mind that the Rails community is growing out of control… plugins are becoming more widespread and advanced, and as such an important aspect of Rails, dependency resolution and versioning needs to become a serious concern if we want to keep plugins quick, fun, and easy to get working. The good news is we don’t need to reinvent the wheel, RubyGems is easily up to the task.

Truth be told, people have been talking about gem plugins from the beginning, and there have been certain in-roads (as with generators)— but it hasn’t been easily built into Rails itself.

Tonight I submitted a patch to do just that. It’s a bit naive, and likely broken in a few places… but hopefully it will spark some serious conversation, some good work, and someone smarter and more savvy than I will take up the torch and do something useful with it.

The idea is simple; install gems and use the [existing] plugin configuration to select what plugins you’d like to load (including version requirements) for each application. It’s backwards compatible; you can still use normal plugins if you’d like— but the gem plugins are structured the same way, have the same capabilities, and come with all the inherent benefits of RubyGems intact.