Newbie question: flickr gem installation


#1

Hi,

I installed the ‘flickr’ gem using ‘gem install flickr’. Everything
seemed to work fine, and the gem shows up in the rDoc as installed.

However, if I run the following script

#! /usr/local/bin/ruby -w

require ‘flickr’
flickr = Flickr.new

I get the following error:

./flickr.rb:15: uninitialized constant Flickr (NameError)

if I run ‘type flickr’ in the terminal I get:

-bash: type: flickr: not found

Where are gems typically installed?

BTW I tried to run “require ‘flickr’” in an IRB session but got an
error. How can I require files in an IRB session?

Thanks for any help!
Ingo W.


#2

Ingo W. wrote:

require ‘flickr’

You probably need to add the line

require ‘rubygems’

to your script preceding the "require ‘flikr’ statement.

http://docs.rubygems.org/


#3

Thanks!

Now my script looks like this:

#! /usr/local/bin/ruby -w

require ‘rubygems’
require ‘flickr’

flickr = Flickr.new

But I am still getting the following error:

./flickr.rb:6: uninitialized constant Flickr (NameError)
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require’
from flickr.rb:4

You probably need to add the line

require ‘rubygems’

to your script preceding the "require ‘flikr’ statement.

http://docs.rubygems.org/


#4

On 23 May 2006, at 22:14, Ingo W. wrote:

require ‘flickr’
flickr = Flickr.new

I get the following error:

./flickr.rb:15: uninitialized constant Flickr (NameError)

The line number indicates that the require ‘flickr’ line has worked
fine, so the file has been loaded okay by the looks of things.

I’ve not used the flickr api, but it looks like it doesn’t have a
class called Flickr in it. Have you had a scan of the documentation
to get a feeling for it?

if I run ‘type flickr’ in the terminal I get:

-bash: type: flickr: not found

I guess that’s because flickr isn’t a command in bash’s path. It’s a
gem for Ruby, not something for the shell (although some Gems (rake,
for example) do instal utility commands).

Where are gems typically installed?

Ah, you can find that out with:

gem env gemp

and my favourite:

cd `gem env gemp`

You may want to find out a bit more about the gem command with:

gem help

BTW I tried to run “require ‘flickr’” in an IRB session but got an
error. How can I require files in an IRB session?

That’s the correct way. As someone else posted, you may have to
require ruby gems first. I do that as a default by having this in
my .profile:

export RUBYOPT=-rubygems

Thanks for any help!

Hope it helps,
Benjohn


#5

On 24 May 2006, at 07:10, I wrote:

The line number indicates that the require ‘flickr’ line has worked
fine, so the file has been loaded okay by the looks of things.

Which is wrong, because the error line number just seems weird.

I’ve not used the flickr api, but it looks like it doesn’t have a
class called Flickr in it. Have you had a scan of the documentation
to get a feeling for it?

I still maintain that - the error you get (NameError) does suggest
that the require worked out, but that there’s no global class called
Flickr.


#6

Ingo W. wrote:

Hi,

I installed the ‘flickr’ gem using ‘gem install flickr’. Everything
seemed to work fine, and the gem shows up in the rDoc as installed.

However, if I run the following script

#! /usr/local/bin/ruby -w

require ‘flickr’
flickr = Flickr.new

I get the following error:

./flickr.rb:15: uninitialized constant Flickr (NameError)

That’s because “require flickr” load flickr.rb you wrote instead of the
one you installed, you need change flickr.rb you wrote to any other
names.

Best regards,

uncutstone


#7

Amazing. Changing the script’s name indeed did the trick. Now playing
with the gem in IRB works, too!

Thanks!
Ingo

uncutstone wu wrote:

Ingo W. wrote:

Hi,

I installed the ‘flickr’ gem using ‘gem install flickr’. Everything
seemed to work fine, and the gem shows up in the rDoc as installed.

However, if I run the following script

#! /usr/local/bin/ruby -w

require ‘flickr’
flickr = Flickr.new

I get the following error:

./flickr.rb:15: uninitialized constant Flickr (NameError)

That’s because “require flickr” load flickr.rb you wrote instead of the
one you installed, you need change flickr.rb you wrote to any other
names.

Best regards,

uncutstone