Michael Durrant
Michael Durrant

Reputation: 96454

Is `require "rubygems"` returning `false` ok?

Requiring "rubygems" gives false, but requiring "appium_lib" gives true. I.e.,

require 'rubygems' # => false
require 'appium_lib' # => true

Is this ok? This is not like trying to require something that really doesn't exist, i.e.:

require 'does_not_existxxxxxxx' # => LoadError: cannot load such file -- does_not_existxxxxxxx

Upvotes: 6

Views: 3881

Answers (2)

Andreas Gnyp
Andreas Gnyp

Reputation: 1840

It should be fine. Requiring a file the second time results in a false response. With load, it's a different thing, which would load (require) the file each time it is requested.

So it just means that irb is starting with rubygems already required, which is not a surprise.

For example, load is heavily used in Rails' development mode, so your changes can immediately be shown.

Since Ruby 1.9 rubygems are automatically required.

Upvotes: 11

Tucker
Tucker

Reputation: 659

When you require a gem, really you’re just placing that gem’s lib directory onto your $LOAD_PATH. If it returns false all that means is that it is already in your $LOAD_PATH.

Requiring a Gem

Upvotes: 3

Related Questions