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

Memcached Security aka Don't Attack GitHub 

March 7, 2018

GitHub recently experienced the largest attack we've seen to date. At the peak, they received

Read More

Ajax on Rails with Unobtrusive JavaScript

March 1, 2018

This blog post is for Rails developers that want to use Ajax in their application using

Read More

The 13 Ruby Conferences You Cannot Miss in 2018

February 28, 2018

Nothing remains constant, especially in technology. As we continue to develop new DevOps

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!