# Gems not working

**URL:** <https://rubytalk.org/t/gems-not-working/38704>\
**Category:** ruby-talk\
**Created:** [28 June 2007 17:30 UTC](https://rubytalk.org/t/gems-not-working/38704 "2007-06-28T17:30:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_Predoehl](https://avatars.discourse-cdn.com/v4/letter/v/8491ac/32.png) [@Vincent\_Predoehl](https://rubytalk.org/u/Vincent_Predoehl)\
**Post date:** [28 June 2007 17:30 UTC](https://rubytalk.org/t/gems-not-working/38704/1 "2007-06-28T17:30:16Z")

</div>

I do not have rails, but I like to use Ruby Gems. I installed gem  
hpricot and when I run my script with 'ruby', it has trouble finding the  
Hpricot library. When I run the same code in IRB, it finds the gem. I  
do have require 'rubygems' before require 'hpricot'. The code fails on  
line 5, where I use the hpricot library for the first time ( which seems  
strange )

require 'rubygems'  
require 'pricot'  
require 'open-uri'  
# load the RedHanded home page  
doc = Hpricot(open("[http://redhanded.hobix.com/index.html](http://redhanded.hobix.com/index.html)"))  
# change the CSS class on links  
(doc/"span.entryPermalink").set("class", "newLinks")  
# remove the sidebar  
(doc/"#sidebar").remove  
# print the altered HTML  
puts doc

This situation occurs when I run the script from teh command line:

ruby hpricot.rb

The same code runs perfectly in IRB. It would seem that IRB knows more  
about gems while the ruby interpretor does not. What can I do about  
this? Thanks.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Alex\_Young](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Alex\_Young](https://rubytalk.org/u/Alex_Young)\
**Post date:** [28 June 2007 18:16 UTC](https://rubytalk.org/t/gems-not-working/38704/2 "2007-06-28T18:16:54Z")

</div>

Vincent Predoehl wrote:

> I do not have rails, but I like to use Ruby Gems. I installed gem  
> hpricot and when I run my script with 'ruby', it has trouble finding the  
> Hpricot library. When I run the same code in IRB, it finds the gem. I  
> do have require 'rubygems' before require 'hpricot'. The code fails on  
> line 5, where I use the hpricot library for the first time ( which seems  
> strange )
> 
> require 'rubygems'  
> require 'pricot'

-----------^ typo?

> **···**
>
> --  
> Alex

---

<div class="post-metadata">

**Author:** ![Ryan\_Davis1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/ryan_davis1/32/1848_2.png) [@Ryan\_Davis1](https://rubytalk.org/u/Ryan_Davis1)\
**Post date:** [28 June 2007 18:37 UTC](https://rubytalk.org/t/gems-not-working/38704/3 "2007-06-28T18:37:40Z")

</div>

name the script different from the thing you are requiring... 'test-hpricot.rb' maybe.

> **···**
>
> On Jun 28, 2007, at 10:30 , Vincent Predoehl wrote:
> 
> > require 'rubygems'  
> > require 'pricot'  
> > ...
> > 
> > This situation occurs when I run the script from teh command line:
> > 
> > ruby hpricot.rb

---

<div class="post-metadata">

**Author:** ![Doan\_Alex](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@Doan\_Alex](https://rubytalk.org/u/Doan_Alex)\
**Post date:** [28 June 2007 18:38 UTC](https://rubytalk.org/t/gems-not-working/38704/4 "2007-06-28T18:38:54Z")

</div>

It's b/c you call your file 'hpricot.rb', rename the file to something  
else and it should work.

> **···**
>
> -----Original Message-----  
> From: [list-bounce@example.com](mailto:list-bounce@example.com) [[mailto:list-bounce@example.com](mailto:list-bounce@example.com)] On Behalf  
> Of Vincent Predoehl  
> Sent: Thursday, June 28, 2007 1:30 PM  
> To: ruby-talk ML  
> Subject: Gems not working
> 
> I do not have rails, but I like to use Ruby Gems. I installed gem  
> hpricot and when I run my script with 'ruby', it has trouble finding the  
> Hpricot library. When I run the same code in IRB, it finds the gem. I  
> do have require 'rubygems' before require 'hpricot'. The code fails on  
> line 5, where I use the hpricot library for the first time ( which seems  
> strange )
> 
> require 'rubygems'  
> require 'pricot'  
> require 'open-uri'  
> # load the RedHanded home page  
> doc = Hpricot(open("[http://redhanded.hobix.com/index.html](http://redhanded.hobix.com/index.html)"))  
> # change the CSS class on links  
> (doc/"span.entryPermalink").set("class", "newLinks") # remove the  
> sidebar (doc/"#sidebar").remove # print the altered HTML puts doc
> 
> This situation occurs when I run the script from teh command line:
> 
> ruby hpricot.rb
> 
> The same code runs perfectly in IRB. It would seem that IRB knows more  
> about gems while the ruby interpretor does not. What can I do about  
> this? Thanks.
> 
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Vincent\_Predoehl](https://avatars.discourse-cdn.com/v4/letter/v/8491ac/32.png) [@Vincent\_Predoehl](https://rubytalk.org/u/Vincent_Predoehl)\
**Post date:** [28 June 2007 18:28 UTC](https://rubytalk.org/t/gems-not-working/38704/5 "2007-06-28T18:28:05Z")

</div>

Alex Young wrote:

> Vincent Predoehl wrote:
> 
> > I do not have rails, but I like to use Ruby Gems. I installed gem  
> > hpricot and when I run my script with 'ruby', it has trouble finding the  
> > Hpricot library. When I run the same code in IRB, it finds the gem. I  
> > do have require 'rubygems' before require 'hpricot'. The code fails on  
> > line 5, where I use the hpricot library for the first time ( which seems  
> > strange )
> > 
> > require 'rubygems'  
> > require 'pricot'
> 
> -----------^ typo?

I saw the typo and fixed it. I regret the typo because it only added to  
the confusion, but I still have the same problem.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Vincent\_Predoehl](https://avatars.discourse-cdn.com/v4/letter/v/8491ac/32.png) [@Vincent\_Predoehl](https://rubytalk.org/u/Vincent_Predoehl)\
**Post date:** [28 June 2007 19:00 UTC](https://rubytalk.org/t/gems-not-working/38704/6 "2007-06-28T19:00:29Z")

</div>

Doan, Alex wrote:

> It's b/c you call your file 'hpricot.rb', rename the file to something  
> else and it should work.

The platform is MacOS X Tiger. I installed hpricot using balloons from  
here and it works:  
[http://balloon.hobix.com/hpricot](http://balloon.hobix.com/hpricot)

The file name was probably the problem though. Either way I got it  
working and I renamed the file.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Alex\_Young](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Alex\_Young](https://rubytalk.org/u/Alex_Young)\
**Post date:** [28 June 2007 18:35 UTC](https://rubytalk.org/t/gems-not-working/38704/7 "2007-06-28T18:35:20Z")

</div>

Vincent Predoehl wrote:

> Alex Young wrote:
> 
> > Vincent Predoehl wrote:
> > 
> > > I do not have rails, but I like to use Ruby Gems. I installed gem  
> > > hpricot and when I run my script with 'ruby', it has trouble finding the  
> > > Hpricot library. When I run the same code in IRB, it finds the gem. I  
> > > do have require 'rubygems' before require 'hpricot'. The code fails on  
> > > line 5, where I use the hpricot library for the first time ( which seems  
> > > strange )
> > > 
> > > require 'rubygems'  
> > > require 'pricot'
> > 
> > -----------^ typo?
> 
> I saw the typo and fixed it. I regret the typo because it only added to the confusion, but I still have the same problem.

What platform is this on? What's the exact error?

> **···**
>
> --  
> Alex
