Reputation: 91
I am currently reading through this guide: http://guides.rubygems.org/what-is-a-gem/
Under the third section ("Requiring code"), it says that if I run require 'rake'
, it should fail, because "because RubyGems isn’t loaded yet.". However, when I run require 'rake'
, (without running require 'rubygems'
, it works! Is the guide incorrect or am I using a wrong version of Ruby or has something changed?
Upvotes: 2
Views: 437
Reputation: 332736
If you have RUBYOPT=rubygems
set in your environment when you launch Ruby, then Ruby Gems will automatically be required. Or if you launch ruby with the argument -rubygems
, which is equivalent. Or if you're using Ruby 1.9 or later, Rubygems should automatically be required.
One (or more) of these things is probably true on your system.
Upvotes: 3
Reputation: 124409
You are probably running Ruby 1.9.
The default Ruby 1.9 package now includes RubyGems by default on most platforms (presently Debian based systems split this out into a separate package). This means that on Ruby 1.9 and above, you will not need to require 'rubygems' in order to load gem libraries.
Upvotes: 6