Reason #66 • March 7th, 2026

Gems

Gems are the standard package format for Ruby libraries, and are the primary way Ruby developers share code with others.

These days, having a format for libraries and some kind of dependency manager is taken for granted (unless you're into Odin or something). But back in 2006 when I started using Ruby, it completely blew my mind that I could run gem install rails on my MacBook and end up with a fully functioning web development stack ready to go.

In particular, the thing that got many of us introduced to Ruby was: gem install rails -> rails new myapp -> cd myapp -> rails server. After which, all of a sudden, there was a web server we could interact with at http://localhost:3000. All ready to go.

Compare this to manually configuring a local Apache + PHP + MySQL stack. Or doing Java or .NET development, requiring you to manually recompile the code before reloading the browser for every little change. It really seemed like magic at the time!

What is a Gem?

Gems are distributed as .gem files. A .gem file is a tarball containing three files:

Building and publishing a gem is as simple as running gem build and gem push, provided you have a gemspec file that describes your gem and its dependencies, and an account on a gem hosting service like rubygems.org or gem.coop.

An example of a minimal gemspec file might look like this:

Ruby
Gem::Specification.new do |spec|
  spec.name    = "my_gem"
  spec.version = "1.0.0"
  spec.authors = ["Your Name"]
  spec.files   = %w[all the files you need bundled with your gem]
end
    

Incredibly simple, though there are additional recommended attributes available. Should you wish to learn more, you can dive deeper into the specification in the documentation.

To make use of a gem, you really don't need to know anything about the format or the spec. You can just run gem install and then require the gem in your code. It just works!

History

RubyGems was originally developed at RubyConf 2003 by Chad Fowler, Jim Weirich, Richard Kilmer, David Black and Paul Brannan.

It remained an external tool for a few years before being included in the Ruby standard library in Ruby 1.9, released in 2007.

The spec itself has remained quite stable over the years with a handful of additions:

The biggest change in the ecosystem since RubyGems was the introduction of the dependency manager Bundler in 2010, which we'll talk about another day.

Reason #67 ?