# Newbie question: flickr gem installation

**URL:** <https://www.ruby-forum.com/t/newbie-question-flickr-gem-installation/95180>\
**Category:** Ruby\
**Created:** [May 23, 2006, 11:14pm UTC](https://www.ruby-forum.com/t/newbie-question-flickr-gem-installation/95180 "2006-05-23T23:14:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [May 23, 2006, 11:14pm UTC](https://www.ruby-forum.com/t/newbie-question-flickr-gem-installation/95180/1 "2006-05-23T23:14:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [May 23, 2006, 11:45pm UTC](https://www.ruby-forum.com/t/newbie-question-flickr-gem-installation/95180/2 "2006-05-23T23:45:46Z")

</div>

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/](http://docs.rubygems.org/)

---

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [May 24, 2006, 7:15am UTC](https://www.ruby-forum.com/t/newbie-question-flickr-gem-installation/95180/3 "2006-05-24T07:15:42Z")

</div>

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/](http://docs.rubygems.org/)

---

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [May 24, 2006, 8:11am UTC](https://www.ruby-forum.com/t/newbie-question-flickr-gem-installation/95180/4 "2006-05-24T08:11:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [May 24, 2006, 8:23am UTC](https://www.ruby-forum.com/t/newbie-question-flickr-gem-installation/95180/5 "2006-05-24T08:23:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [May 24, 2006, 8:24am UTC](https://www.ruby-forum.com/t/newbie-question-flickr-gem-installation/95180/6 "2006-05-24T08:24:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [May 24, 2006, 12:52pm UTC](https://www.ruby-forum.com/t/newbie-question-flickr-gem-installation/95180/7 "2006-05-24T12:52:55Z")

</div>

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
