Goodbye ubygems


source code form.jpg

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

Take Out The Papers And The Trash

August 17, 2018

How to clean and clear large tables in MySQL

From time to time our data team gets requests for

Read More

Ruby on Rails vs PHP

May 16, 2018

There’s more than one way to build a web application. No matter what type of application you are

Read More

What to Look for When Considering Application Hosting

May 8, 2018

Cloud computing has made hosting business-critical applications easier and less expensive.

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 Here!