views:

267

answers:

1

Hi everyone, I'm trying to get started with twitter4r but I'm having some issues:

Why I can't load the gem in IRB?

$ sudo gem install twitter4r
Successfully installed twitter4r-0.3.2
1 gem installed
Installing ri documentation for twitter4r-0.3.2...
Installing RDoc documentation for twitter4r-0.3.2...

$ irb
>> require 'rubygems'
=> false
>> require 'twitter4r'
LoadError: no such file to load -- twitter4r
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`require'
       from (irb):2

I've downloaded the http://files.rubyforge.vm.bytemark.co.uk/twitter4r/twitter4rails.post-0_2_4.zip app and it works only with twitter4r-0.2.4 and NOT with last version twitter4r-0.3.2:

$ script/server
./script/../config/boot.rb:26:Warning: Gem::SourceIndex#search support
for String patterns is deprecated, use #find_name
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
Exiting
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require': no such file to load -- twitter/rails
(MissingSourceFile)
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`require'
       from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:495:in `require'
       from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:342:in `new_constants_in'
       from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:495:in `require'
       from /Users/leonardodarioperna/Projects/Kaaaki/marrakaaaki/
twitter4rails.post-0_2_4/config/environment.rb:64
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`require'
       from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:495:in `require'
        ... 23 levels...
       from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`require'
       from script/server:3

Last thing, in the /config/environment.rb I need to specify:

         RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION  

if I use my last rails version:

        RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION 

I get this error:

$ script/server -p3002
=> Booting Mongrel
=> Rails 2.3.4 application starting on http://0.0.0.0:3000
/Library/Ruby/Site/1.8/rubygems.rb:280:in `activate': can't activate
activerecord (= 1.15.6, runtime) for [], already activated
activerecord-2.3.4 for ["rails-2.3.4"] (Gem::LoadError)
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:35:in
`require'
       from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/
active_support/dependencies.rb:156:in `require'
       from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/
active_support/dependencies.rb:521:in `new_constants_in'
       from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/
active_support/dependencies.rb:156:in `require'
       from /Library/Ruby/Gems/1.8/gems/twitter4r-0.2.4/lib/twitter/rails.rb:
6
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`require'
       from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/
active_support/dependencies.rb:156:in `require'
        ... 8 levels...
       from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/commands/server.rb:
84
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`require'
       from script/server:3
 

And that's all :-)

Thank you!

+4  A: 

Confusingly the gem name and require name are different. The following works correctly in irb:

require 'twitter'
Mike Buckbee
I hate it when that happens.
Tim Snowhite
+1 - that's really insane ... time for some additional coding conventions. :)
Webbisshh
OMG, that's crazy.Last thing, I've installed the "twitter" gem as well (http://twitter.rubyforge.org/) how can I distinguish them in IRB?
Leonardo Dario Perna