Goodbye ubygems


source code form

No we're not hating on RubyGems. This is about ubygems and that's not a typo. There was a file named ubygems.rb and it has been removed from Ruby 2.5.

Back in the day, RubyGems didn't ship with Ruby. You have to install it separately. To use RubyGems, you need to require it like any other Ruby code. You'd write require 'rubygems' before using it.

Ruby provides the -r switch on the command line. Here's the description.

  -rlibrary       require the library before executing your script

-r is used to require the library from the command line without needing to require it inside your script.

The switch -rubygems looks for a file named ubygems.rb. There was no separate -rubygems switch. This is just the -r switch with ubygems as the library.

The file is actually just one line: require 'rubygems'. It didn't really have a use aside from -rubygems looking better than -rrubygems. Starting with Ruby 1.9, RubyGems ships built-in with Ruby so you don't have to use either.

The code below doesn't work on Ruby 2.5 anymore though it works on Ruby 2.4 and earlier. But there's probably not too many code using the -rubygems from the command line.

ruby -rubygems -e 'puts 1'

Traceback (most recent call last):
    1: from /Users/crigor/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/Users/crigor/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- ubygems (LoadError)

Start a Free Trial:

Engine Yard is so much more than just a Ruby on Rails PaaS platform. But don't just take our word for it. Request a free trial of Engine Yard platform today, and one of our Engineers will be in contact within one business day to get you going.


Related posts

RubyConf Round Up

November 27, 2018

The City: Los Angeles, California

Read More

It's Almost Time For Ruby Conf 2018!

November 6, 2018

It’s autumn and November is right around the corner! We all know what this means…

Read More

Jekyll and Engine Yard: A Match Made in The Clouds

October 29, 2018

Blogging is without a doubt the most important way to get your ideas out to the world, whether

Read More

Christopher Rigor

Christopher Rigor is a Senior Technical Evangelist at Engine Yard. He’s a long time Rails user, system administrator, and recently became a contributor of RailsInstaller. Previously, he was the DevOps Support Manager for Asia-Pacific at Engine Yard.
Find me on:


Subscribe to our Blog