From: "NAKAMURA, Hiroshi" Date: 2007-07-26T10:55:18+09:00 Subject: Re: Import gem to Ruby 1.9 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, Eric Hodel wrote: >> This mail is for the topic '4. What $LOAD_PATH order should be?' >> # We replace Ruby's require with our own, which is capable of >> # loading gems on demand. >> # >> # When you call require 'x', this is what happens: >> # * If the file can be loaded from the existing Ruby loadpath, it >> # is. >> # * Otherwise, installed gems are searched for a file that matches. >> # If it's found in gem 'y', that gem is activated (added to the >> # loadpath). >> # >> # The normal require functionality of returning false if >> # that file has already been loaded is preserved. > > The work of adding the gem's require_paths to $LOAD_PATH happens in > Gem::activate. > >> Custom 'require' at first try to load the specified feature name from; >> [-I, ENV_RUBYLIB, SITELIBDIR, RUBYLIBDIR, .] >> When it raises LoadError then add GEMs at the top of $LOAD_PATH and try >> to load the feature from; >> [GEMs, -I, ENV_RUBYLIB, SITELIBDIR, RUBYLIBDIR, .] > > The behavior you describe is how 0.9.2 and previous worked. Doh. Sorry for bothering you. I updated rubygems with 'gem update --system' and I confirmed that the behavior change you explained. > With GEMs before -I, the gem version can get loaded instead of the -I > version. > > With GEMs after -I, the -I version will always be preferred. Agreed. So the topic 4-2 should be; 4. What $LOAD_PATH order should be? 4-2. after requiring rubygems? [-I, ENV_RUBYLIB, GEMs, SITELIBDIR, RUBYLIBDIR, .] As I wrote in the latest summary, this behavior should be up to RubyGems team. RubyGems team can control this behavior. Then why I raised the topic to this thread? Because I considered that RubyGems may be enabled by default. Eric, - you are thinking that $LOAD_PATH does not include GEMs dirs by default. - you think that 'hooking -r option' is all the requirement for ruby/1.9.1 to bundle RubyGems. Right? So the expected behavior is as follows? % gem install httpclient (done) % ruby -rhttpclient -e 'p HTTPClient.get_content("http://localhost/")' => ruby: no such file to load -- httpclient (LoadError) % ruby -rgem -rhttpclient -e '...' => (runs fine) Of course we can direct users to use RUBYOPT=-rgem trick to hide this detail though. I think RubyGems should not be enabled by default but once after using RubyGems, GEMs dir should be checked without any trick until the time I run 'gem cleanup'. Of course any other Ruby based new packaging system can do the same thing. Isn't it the behavior we expect to a packaging system? As you know, it requires rather complicated 'require-hook' feature to ruby such as; - ruby checks "custom_require.rb" file in SITELIBDIR and load it before enabling any feature. It may be too much for ruby/1.9.1. 'To use gem, run ruby with "-rgem" always' can be accepted for the first step I think. >> Once an user found this answer, it gets easier to track down a loader >> problem in soap4r-ml. The rest I want to know is where 'gem "soap4r"' >> should be added in RoR environment... (I've not yet been a RoR user.) > > config/environment.rb is the correct place in RoR. Thanks! It much help soap4r users. // NaHi -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) iQEVAwUBRqf+6x9L2jg5EEGlAQIkGQf/VypyqXj1yASSuaZSAtBVIzvHUkX+KiYj z0GJjVztRXtrSlyqECoLNfm08hq9rsnQYR0p4ObTPzZU5GFADbVArnEE+gmFr/Mx HN5nI7cYynt2ktHiNFuBS3z3uqLdyUBZM9u1nZPV51RQ5lvab7TV+mcgVrPqbI7X vldMonN36DdB0PWyyZhYurq9RF1rEnYwYpDsljcv8ryo+Ourr4E+evkTkRgLrtOm Hoee7UxngppEaZo/QegGrYFYwGh6wB/sG2mTrdDLbz2xIJMXMgte9P6+Yhn+rG39 BXAYY4/Qx9WROcUIyE48DT2IA3u/Y/gy5eWRXk8isGi5f09nA/xwQw== =oWFH -----END PGP SIGNATURE-----