On Apr 28, 2011, at 12:07 AM, Jes=FAs Gabriel y Gal=E1n wrote:

> On Wed, Apr 27, 2011 at 5:56 PM, Zhi-Qiang Lei =
<zhiqiang.lei / gmail.com> wrote:
>> Hi,
>>=20
>> I'm trying to package a library into a gem. I write the main file =
with autoload, just like Rack's.
>>=20
>> module RenrenAPI
>>=20
>>  autoload :Authentication, "renren_api/authentication"
>>  autoload :SignatureCalculator, "renren_api/signature_calculator"
>>  autoload :HTTPAdapter, "renren_api/http_adapter"
>>=20
>> end
>>=20
>> But when I use the gem, I get a LoadError.
>>=20
>>> RenrenAPI::Authentication
>> LoadError: no such file to load -- renren_api/authentication
>>=20
>> The file does exist. Does anyone can tell me what the problem is with =
my library, which does not happen to Rack.
>=20
> You can check the load path:
>=20
> p $:
>=20
> before your code to check where Ruby is looking for requires. BTW,
> Ruby 1.9 removed "." from the load path.
>=20
> Jesus.
>=20


It shows that the lib directory is in the load path. =
(/Users/siegfried/.rvm/gems/ruby-1.9.2-head/gems/renren-api-0.3.1/lib)

bogon% irb
ruby-1.9.2-head :001 > require "renren_api"
 =3D> true=20
ruby-1.9.2-head :002 > RenrenAPI::Authentication
LoadError: no such file to load -- renren_api/authentication
	from (irb):2
	from /Users/siegfried/.rvm/rubies/ruby-1.9.2-head/bin/irb:16:in =
`<main>'
ruby-1.9.2-head :003 > p $:
["/Users/siegfried/.rvm/gems/ruby-1.9.2-head/gems/renren-api-0.3.1/lib", =
"/Users/siegfried/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1", =
"/Users/siegfried/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/x86=
_64-darwin10.6.0", =
"/Users/siegfried/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby", =
"/Users/siegfried/.rvm/rubies/ruby-1.9.2-head/lib/ruby/vendor_ruby/1.9.1",=
 =
"/Users/siegfried/.rvm/rubies/ruby-1.9.2-head/lib/ruby/vendor_ruby/1.9.1/x=
86_64-darwin10.6.0", =
"/Users/siegfried/.rvm/rubies/ruby-1.9.2-head/lib/ruby/vendor_ruby", =
"/Users/siegfried/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1", =
"/Users/siegfried/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/x86_64-darwin=
10.6.0"]

The directory structure is:

|~lib/
| |~renren_api/
| | |-authentication.rb
| | |-http_adapter.rb
| | `-signature_calculator.rb
| `-renren_api.rb

The code I mentioned is the content of lib/renren_api.rb

Best regards,
Zhi-Qiang Lei
zhiqiang.lei / gmail.com