Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3830

Re: LoadPath and require confusion, please explain

From Eugen Ciur <ciur.eugen@gmail.com>
Newsgroups comp.lang.ruby
Subject Re: LoadPath and require confusion, please explain
Date 2011-05-02 04:40 -0500
Organization Service de news de lacave.net
Message-ID <20f2c407df4415d42c965c8e8f251470@ruby-forum.com> (permalink)
References <2f924ae07653151e6e47db274f29bc42@ruby-forum.com> <ea962f54b488388ca9cea05b10caf333@ruby-forum.com>

Show all headers | View raw


Lucky Dev wrote in post #996171:
> But when i say require "something" , something.rb should be present in
> the loadpath for the require call to return success....
>

Nope. Look, when we require arel (for example), although it is not in
$LOAD_PATH, ruby will use paths provided by gem library (as I said in
post before) to find where is arel localted.


 $ ruby -e "puts require 'arel'"
 true


If has found 'arel' library (my load_path is almost same as your - no
arel there)

But, when we disable gems as in command below:

 $ ruby -e "puts require 'arel'" --disable-gems
 -e:1:in `require': no such file to load -- arel (LoadError)
   from -e:1:in `<main>'

Ruby fails to find arel library, because it ignores $GEM_HOME and
$GEM_PATH this time, and search only in $LOAD_PATH.

'--disable-gems' option is your answer.

----
http://blog.eugen.co

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

LoadPath and require confusion, please explain Lucky Dev <lucky.developer@gmail.com> - 2011-05-02 01:35 -0500
  Re: LoadPath and require confusion, please explain Eugen Ciur <ciur.eugen@gmail.com> - 2011-05-02 02:26 -0500
  Re: LoadPath and require confusion, please explain Lucky Dev <lucky.developer@gmail.com> - 2011-05-02 04:15 -0500
    Re: LoadPath and require confusion, please explain OZAWA Sakuro <sakuro@2238club.org> - 2011-05-02 04:22 -0500
    Re: LoadPath and require confusion, please explain Eugen Ciur <ciur.eugen@gmail.com> - 2011-05-02 04:40 -0500
      Re: LoadPath and require confusion, please explain Lucky Dev <lucky.developer@gmail.com> - 2011-05-03 11:37 -0500

csiph-web