Forum: Ruby Newbie question: flickr gem installation

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3504745159d79c585e4f7df8df76aa10?d=identicon&s=25 Ingo Weiss (ingoweiss)
on 2006-05-23 23:14
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 Weiss
3afd3e5e05dc9310c89aa5762cc8dd1d?d=identicon&s=25 Timothy Hunter (Guest)
on 2006-05-23 23:45
(Received via mailing list)
Ingo Weiss wrote:

>require 'flickr'
>
>
You probably need to add the line

require 'rubygems'

to your script preceding the "require 'flikr' statement.

http://docs.rubygems.org/
3504745159d79c585e4f7df8df76aa10?d=identicon&s=25 Ingo Weiss (ingoweiss)
on 2006-05-24 07:15
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/
Ffcb418e17cac2873d611c2b8d8d891c?d=identicon&s=25 Benjohn Barnes (Guest)
on 2006-05-24 08:11
(Received via mailing list)
On 23 May 2006, at 22:14, Ingo Weiss 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
Ffcb418e17cac2873d611c2b8d8d891c?d=identicon&s=25 Benjohn Barnes (Guest)
on 2006-05-24 08:23
(Received via mailing list)
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.
288733e11db1c6dbbf50871d2c6738c6?d=identicon&s=25 Uncutstone Wu (uncutstone)
on 2006-05-24 08:24
Ingo Weiss 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
3504745159d79c585e4f7df8df76aa10?d=identicon&s=25 Ingo Weiss (ingoweiss)
on 2006-05-24 12:52
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 Weiss 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
This topic is locked and can not be replied to.