Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 575
Michael Durrant Avatar asked Apr 25 '15 12:04

Michael Durrant


2 Answers

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.

like image 131
Andreas Gnyp Avatar answered Dec 12 '22 12:12

Andreas Gnyp


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

like image 45
Tucker Avatar answered Dec 12 '22 11:12

Tucker