djibouti33
djibouti33

Reputation: 12132

Can't get Twitter gem to load - no such file

I'm running Ruby v1.8.7 and Rails v3.0.9.

I'm trying to use this twitter gem: http://twitter.rubyforge.org/, v1.7.0

The directions state you need to:

require 'rubygems'
require 'twitter'

However, I'm getting this error:

LoadError
no such file to load -- twitter

I read on SO that the 1.7.0 gem isn't compatible with Ruby 1.8.7, so I downgraded to 0.9 (the version the SO answer mentioned was compatible with 1.8.x) and that still didn't work.

One thing that's weird is that if I fire up irb, and include rubygems first, I can include twitter with no problems.

I had to install the gem using sudo, but I don't think that should be the problem.

Any ideas how I can successfully include this twitter gem into my application? It looks super easy to use, once I can get over this hurdle.

Update: I tried adding

gem 'twitter'

to my Gemfile and ran bundle install, and now I get a Phusion Passenger error:

Ruby (Rack) application could not be started
Could not find twitter-1.7.1 in any of the sources (Bundler::GemNotFound)

Upvotes: 2

Views: 3280

Answers (2)

djibouti33
djibouti33

Reputation: 12132

So it turns out I was actually able to install twitter v.1.7.1

Other information I received from around the web that I'd need to downgrade to 0.9.0 turns out to be false.

I ran:

sudo gem list

And compared the versions of specific gems with what I found here: https://github.com/jnunemaker/twitter/blob/master/HISTORY.md (I simply searched for the word 'dependency' to see which versions twitter cared about.

I also found this diff: https://github.com/jnunemaker/twitter/commit/ac8114c1f6ba2da20c2267d3133252c2ffc6b6a3

And I compared the gems listed there with what I had installed, and I just made sure my system lined up with what I was seeing in the version notes. Oftentimes what happened is that I had multiple versions of a gem, and for some reason, the lower version was taking precedence.

I'm not sure why I still have to add

gem 'twitter', '1.7.1'

to my Gemfile, but alas, that's the last step required in order to get this stuff working.

Phew!

Upvotes: 1

Muhammad Sannan Khalid
Muhammad Sannan Khalid

Reputation: 3137

you need to require the twitter gem in your Gemfile. Run bundle install, now check again.

gem 'twitter'

Upvotes: 6

Related Questions