[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Install hpricot on Leopard

Colin Summers

11/1/2007 4:51:00 AM

Oh, this was working SO nicely until I upgraded the OS...

I tried running my little site spider to keep my archive up-to-date
and I got an error about mechanize not being available. No problem,
I'll just fire up gem and install it. Not so fast...

It requires hpricot and
sudo gem install hpricot
gave me errors that led me to the realization that new OS meant new
compilers and the installation of XCode 3.0. (I'm quite new to the CLI
stuff.)

Once I did that, hpricot and mechanize both installed okay. But I get:

/usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/mechanize/
inspect.rb:44: undefined method `pretty_inspect' for class
`WWW::Mechanize::Page' (NameError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/
mechanize.rb:42
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
32:in `require'
from scrape.rb:13

Clues?

Thanks.
--Colin


6 Answers

John Joyce

11/1/2007 5:53:00 AM

0


On Oct 31, 2007, at 11:50 PM, Colin Summers wrote:

> Oh, this was working SO nicely until I upgraded the OS...
>
> I tried running my little site spider to keep my archive up-to-date
> and I got an error about mechanize not being available. No problem,
> I'll just fire up gem and install it. Not so fast...
>
> It requires hpricot and
> sudo gem install hpricot
> gave me errors that led me to the realization that new OS meant new
> compilers and the installation of XCode 3.0. (I'm quite new to the CLI
> stuff.)
>
> Once I did that, hpricot and mechanize both installed okay. But I get:
>
> /usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/mechanize/
> inspect.rb:44: undefined method `pretty_inspect' for class
> `WWW::Mechanize::Page' (NameError)
> from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 27:in `require'
> from /usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/
> mechanize.rb:42
> from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 32:in `require'
> from scrape.rb:13
>
> Clues?
>
> Thanks.
> --Colin
>
>
Make sure you use
sudo install gem_name_here --include-dependencies

Also make sure your spider has the right shebang at the beginning. #!
usr/bin/or/whatever
Using the default Ruby on Leopard is definitely feasible now, but the
path might be different from your old one.

Now make sure you're requiring all the right stuff.
require 'rubygems'
require 'gem_name_here'


Colin Summers

11/2/2007 3:13:00 AM

0

The first bit of scrape.rb

#! /usr/local/bin/ruby
# scrape.rb
# June 13 2007. Started writing my first Ruby program.
# June 16 2007. It is doing most of everything I wanted it to.
# Colin Summers. colin@mightycheese.com

require 'rubygems' # the module for Ruby that keeps modules up to
date
require 'cgi'
require 'open-uri' # http module used by mechanize
require 'hpricot'
require 'mechanize' # a nicely wrapped browser client

Agent = WWW::Mechanize.new # there's one browser agent we'll use
globally, so it stores the cookies

MacBookPro:spider colin$ which ruby
/usr/local/bin/ruby
MacBookPro:spider colin$ ruby -v
ruby 1.8.4 (2005-12-24) [i686-darwin8.10.1]

Same error still:
MacBookPro:spider colin$ ruby scrape.rb
/usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/mechanize/
inspect.rb:44: undefined method `pretty_inspect' for class
`WWW::Mechanize::Page' (NameError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/
mechanize.rb:42
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
32:in `require'
from scrape.rb:14

Does anyone have mechanize working on Leopard?

--Colin


Ron Mr.

11/2/2007 3:27:00 AM

0

Am I the only one that sees that hpricot is installed by default on
leopard?

-Ron

On Nov 1, 2007, at 11:12 PM, Colin Summers wrote:

> The first bit of scrape.rb
>
> #! /usr/local/bin/ruby
> # scrape.rb
> # June 13 2007. Started writing my first Ruby program.
> # June 16 2007. It is doing most of everything I wanted it to.
> # Colin Summers. colin@mightycheese.com
>
> require 'rubygems' # the module for Ruby that keeps modules up to
> date
> require 'cgi'
> require 'open-uri' # http module used by mechanize
> require 'hpricot'
> require 'mechanize' # a nicely wrapped browser client
>
> Agent = WWW::Mechanize.new # there's one browser agent we'll use
> globally, so it stores the cookies
>
> MacBookPro:spider colin$ which ruby
> /usr/local/bin/ruby
> MacBookPro:spider colin$ ruby -v
> ruby 1.8.4 (2005-12-24) [i686-darwin8.10.1]
>
> Same error still:
> MacBookPro:spider colin$ ruby scrape.rb
> /usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/mechanize/
> inspect.rb:44: undefined method `pretty_inspect' for class
> `WWW::Mechanize::Page' (NameError)
> from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 27:in `require'
> from /usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/
> mechanize.rb:42
> from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 32:in `require'
> from scrape.rb:14
>
> Does anyone have mechanize working on Leopard?
>
> --Colin
>
>


Peter Szinek

11/2/2007 8:09:00 AM

0

Hi,

> MacBookPro:spider colin$ which ruby
> /usr/local/bin/ruby
> MacBookPro:spider colin$ ruby -v
> ruby 1.8.4 (2005-12-24) [i686-darwin8.10.1]
>
> Same error still:
> MacBookPro:spider colin$ ruby scrape.rb
> /usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/mechanize/
> inspect.rb:44: undefined method `pretty_inspect' for class
> `WWW::Mechanize::Page' (NameError)
> from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 27:in `require'
> from /usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/
> mechanize.rb:42
> from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 32:in `require'
> from scrape.rb:14

I am not sure this is leopard-related. I have the same bug submitted to
the scRUBYt! lighthouse:

http://scrubyt.lighthouseapp.com/projects/2912/tickets/17-undefined-method-pretty_inspect-for-class-www-mech...

and AFAIK this happens both on win32 and linux (ubuntu, at least). So I
believe this is a mechanize bug, introduced in 0.6.10. I have tried to
contact Aaron Patterson but got no response. I guess we should file a bug.

Cheers,
Peter

___
http://www.rubyra...
http://s...

Ehud Rosenberg

11/15/2007 9:32:00 AM

0

Happens for me as well, on ubuntu 6.10, after a clean install of
mechanize with dependencies.
Any ideas?

Ehud Rosenberg

11/15/2007 9:59:00 AM

0