# Gems not working

**URL:** <https://www.ruby-forum.com/t/gems-not-working/108051>\
**Category:** Ruby\
**Created:** [June 28, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/gems-not-working/108051 "2007-06-28T19:30:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [June 28, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/gems-not-working/108051/1 "2007-06-28T19:30:10Z")

</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.

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [June 28, 2007, 8:18pm UTC](https://www.ruby-forum.com/t/gems-not-working/108051/2 "2007-06-28T20:18:15Z")

</div>

Vincent P. 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?

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [June 28, 2007, 8:28pm UTC](https://www.ruby-forum.com/t/gems-not-working/108051/3 "2007-06-28T20:28:05Z")

</div>

Alex Y. wrote:

> Vincent P. 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.

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [June 28, 2007, 8:39pm UTC](https://www.ruby-forum.com/t/gems-not-working/108051/4 "2007-06-28T20:39:21Z")

</div>

On Jun 28, 2007, at 10:30 , Vincent P. wrote:

> require ‘rubygems’  
> require ‘pricot’  
> …
> 
> This situation occurs when I run the script from teh command line:
> 
> ruby hpricot.rb

name the script different from the thing you are requiring… ‘test-  
hpricot.rb’ maybe.

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [June 28, 2007, 8:36pm UTC](https://www.ruby-forum.com/t/gems-not-working/108051/5 "2007-06-28T20:36:19Z")

</div>

Vincent P. wrote:

> > > 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?

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [June 28, 2007, 8:40pm UTC](https://www.ruby-forum.com/t/gems-not-working/108051/6 "2007-06-28T20:40:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [June 28, 2007, 9:00pm UTC](https://www.ruby-forum.com/t/gems-not-working/108051/7 "2007-06-28T21:00:04Z")

</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.
