mac - hpricot problems

S

Sergio Ruiz

i am trying to get hpricot running (so i can run mechanize) and am
running into problems..

i have installed hpricot a few times (just deleted it from the gems) and
did a fresh 'gem install hpricot'..

the problem i have is..

every time i try to run it, i get:


irb(main):003:0> require 'hpricot'
LoadError: no such file to load -- hpricot
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`gem_original_require'
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`require'
from (irb):3


anyone have any ideas?

thanks!
 
D

Daniel Waite

Sergio said:
i am trying to get hpricot running (so i can run mechanize) and am
running into problems..

i have installed hpricot a few times (just deleted it from the gems) and
did a fresh 'gem install hpricot'..

the problem i have is..

every time i try to run it, i get:


irb(main):003:0> require 'hpricot'
LoadError: no such file to load -- hpricot
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`gem_original_require'
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`require'
from (irb):3


anyone have any ideas?

I'm going from memory, but I believe you have to require rubygems first.
Example:

require 'rubygems'
require 'hpricot'

Hpricot.XML(some_feed)
 
S

Sergio Ruiz

require 'rubygems'
require 'hpricot'

Hpricot.XML(some_feed)

i forgot to mention that at first.. yes..

i did require 'rubygems'..

here's another snapshot..



irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'hpricot'
LoadError: no such file to load -- hpricot
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`gem_original_require'
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`require'
from (irb):2
irb(main):003:0>
irb(main):004:0*


thanks!
 
R

Ryan Davis

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'hpricot'
LoadError: no such file to load -- hpricot

% find `gem env gemdir`/gems/hpricot-* -name \*.bundle -ls
13756612 240 -rw-r--r-- 1 root ryan 120824 Jul 11
10:20 /usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/ext/hpricot_scan/
hpricot_scan.bundle
13756606 240 -rwxr-xr-x 1 root ryan 120824 Jul 11
10:20 /usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/i686-linux/
hpricot_scan.bundle

(no idea why one is under i686-linux... but you should definitely see
an hpricot_scan.bundle if you installed correctly.

If it is missing, what is the output from: http://www.zenspider.com/
~ryand/wtf.rb ?
what is the output of 'yes | sudo gem uninstall hpricot; yes 3 | sudo
gem install hpricot' ?
 
M

mortee

Hi,

I just ran into the same trouble with Hpricot on OS X too. I can install
any version using gem install, but I get errors when trying to use the lib.

I tried the ruby and jruby variant, none helped. I tried to fetch the
source from svn and build it. After fiddling a bit with the ext's
generated makefile (it included -arch i386) I could get it to build, and
pass tests. Now it's also installed as hpricot (0.6.155). Yet it tells me:

$ ruby -rubygems -rhpricot -e ''
ruby: no such file to load -- hpricot (LoadError)

Ryan said:
% find `gem env gemdir`/gems/hpricot-* -name \*.bundle -ls
13756612 240 -rw-r--r-- 1 root ryan 120824 Jul 11 10:20
/usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/ext/hpricot_scan/hpricot_scan.bundle

13756606 240 -rwxr-xr-x 1 root ryan 120824 Jul 11 10:20
/usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/i686-linux/hpricot_scan.bundle


(no idea why one is under i686-linux... but you should definitely see an
hpricot_scan.bundle if you installed correctly.

If it is missing, what is the output from:
http://www.zenspider.com/~ryand/wtf.rb ?

I checked, and I have both hpricot_scan.bundle, but after building
specifically for the ppc platform, the second one is in a
universal-darwin8.0 subdirectory.

mortee

Some system info:

$ sw_vers
ProductName: Mac OS X Server
ProductVersion: 10.4.10
BuildVersion: 8R218

$ ruby -ropen-uri -e
'eval(open("http://www.zenspider.com/~ryand/wtf.rb").read)'
ruby:

ruby 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0]

uname:

Darwin neomax.hu 8.10.0 Darwin Kernel Version 8.10.0: Wed May 23
16:50:59 PDT 2007; root:xnu-792.21.3~1/RELEASE_PPC Power Macintosh powerpc

config:

prefix = /usr/local
SHELL = /bin/sh
LIBS = -lpthread -ldl -lobjc
build = i686-apple-darwin8.10.1
target = i686-apple-darwin8.10.1
CC = gcc
CFLAGS = -g -O2 -fno-common -pipe -fno-common
LDFLAGS =
CCDLFLAGS = -fno-common
LDSHARED = cc -dynamic -bundle -undefined suppress -flat_namespace
LIBRUBY_LDSHARED = cc -dynamiclib -undefined suppress -flat_namespace

gcc:

powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build
5370)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

rubygems:

actionmailer (1.3.3)
actionpack (1.13.3)
actionwebservice (1.2.3)
activerecord (1.15.3)
activesupport (1.4.2)
cgi_multipart_eof_fix (2.1)
daemons (1.0.7)
fastthread (1.0)
gem_plugin (0.2.2)
hpricot (0.6.155)
mongrel (1.0.1)
rails (1.2.3)
rake (0.7.3)
rfm (1.0.0)
sources (0.0.1)
sqlite3-ruby (1.2.1)

inline:


Testing: :
 
P

Phrogz

I just ran into the same trouble with Hpricot on OS X too. I can install
any version using gem install, but I get errors when trying to use the lib.

FWIW, no trouble here. Hand-compiled ruby 1.8.6, using rubygems 0.9.4.


Slim2:~ phrogz$ sudo gem install hpricot
Password:
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i686-darwin8.9.1)
1. hpricot 0.6 (mswin32)
2. hpricot 0.6 (jruby)
3. hpricot 0.6 (ruby)
4. hpricot 0.5.140 (mswin32)
5. hpricot 0.5.140 (jruby)
6. hpricot 0.5.140 (ruby)
7. Skip this gem
8. Cancel installation
Building native extensions. This could take a while...
Successfully installed hpricot-0.6
Installing ri documentation for hpricot-0.6...
Installing RDoc documentation for hpricot-0.6...

Slim2:~ phrogz$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'hpricot'
=> true
irb(main):003:0> Hpricot
=> Hpricot
 
M

mortee

Phrogz said:
FWIW, no trouble here. Hand-compiled ruby 1.8.6, using rubygems 0.9.4.


Slim2:~ phrogz$ sudo gem install hpricot
Password:
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i686-darwin8.9.1)
1. hpricot 0.6 (mswin32)
...

Yes, but as gem's output shows, you have an Intel-based Mac. The one I
use is ppc, as I guess the OP too. That may quite make a difference in
this case.

mortee
 
S

Sergio Ruiz

% find `gem env gemdir`/gems/hpricot-* -name \*.bundle -ls

hmmm..

i get ..

sergio-powerbook-g4-12:~ sergio$ find `gem env gemdir`/gems/hpricot-*
-name \*.bundle -ls
1185120 184 -rwxr-xr-x 1 root wheel 92580 Sep 27 18:23
/usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/ext/hpricot_scan/hpricot_scan.bundle
1185122 184 -rwxr-xr-x 1 root wheel 92580 Sep 27 18:23
/usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/i686-linux/hpricot_scan.bundle

checking everything else next..
 
W

_why

i get ..

sergio-powerbook-g4-12:~ sergio$ find `gem env gemdir`/gems/hpricot-*
-name \*.bundle -ls
1185120 184 -rwxr-xr-x 1 root wheel 92580 Sep 27 18:23
/usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/ext/hpricot_scan/hpricot_scan.bundle
1185122 184 -rwxr-xr-x 1 root wheel 92580 Sep 27 18:23
/usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/i686-linux/hpricot_scan.bundle

checking everything else next..

Say, would you mind sending me your mkmf.log from that first directory,
Sergio? It should be right in `ext/hpricot_scan/` and it would also
be nice to see the output of `ruby -rrbconfig -e "p Config::CONFIG"` as
well.

Maybe try a plain setup.rb installer for Hpricot?

http://code.whytheluckystiff.net/dist/hpricot-0.6.tgz

_why
 
S

Sergio Ruiz

Say, would you mind sending me your mkmf.log from that first directory,
Sergio? It should be right in `ext/hpricot_scan/` and it would also
be nice to see the output of `ruby -rrbconfig -e "p Config::CONFIG"` as
well.

here you go:

have_library: checking for main() in -lc... -------------------- yes

"gcc -o conftest -I. -I/usr/local/lib/ruby/1.8/powerpc-darwin8.10.0 -I.
-g -O2 -fno-common -pipe -fno-common conftest.c -L"/usr/local/lib"
-lruby-static -lc -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
/* end */

--------------------




this is really messy..

ruby -rrbconfig -e "p
Config::CONFIG"{"sitedir"=>"/usr/local/lib/ruby/site_ruby",
"MAKEFILES"=>"Makefile", "LIBRUBY"=>"libruby.1.8.6.dylib",
"MAKEDIRS"=>"mkdir -p", "PACKAGE_VERSION"=>"", "GREP"=>"/usr/bin/grep",
"prefix"=>"/usr/local", "COMMON_LIBS"=>"",
"rubylibdir"=>"/usr/local/lib/ruby/1.8",
"target"=>"powerpc-apple-darwin8.10.0", "DLLWRAP"=>"", "AR"=>"ar",
"target_alias"=>"", "MANTYPE"=>"doc",
"docdir"=>"/usr/local/share/doc/$(PACKAGE)", "RDOCTARGET"=>"",
"dvidir"=>"/usr/local/share/doc/$(PACKAGE)", "AS"=>"as", "GNU_LD"=>"no",
"MAINLIBS"=>"", "WINDRES"=>"", "XCFLAGS"=>" -DRUBY_EXPORT",
"datarootdir"=>"/usr/local/share", "RUBY_INSTALL_NAME"=>"ruby",
"LN_S"=>"ln -s",
"archdir"=>"/usr/local/lib/ruby/1.8/powerpc-darwin8.10.0",
"LINK_SO"=>"", "MINIRUBY"=>"./miniruby", "DLDLIBS"=>"", "EXEEXT"=>"",
"target_vendor"=>"apple", "RUNRUBY"=>"./miniruby $(srcdir)/runruby.rb
--extout=.ext --", "DESTDIR"=>"", "sbindir"=>"/usr/local/sbin",
"LIBPATHENV"=>"DYLD_LIBRARY_PATH", "sitearch"=>"powerpc-darwin8.10.0",
"psdir"=>"/usr/local/share/doc/$(PACKAGE)", "host_cpu"=>"powerpc",
"DLEXT2"=>"", "LIBS"=>"-lpthread -ldl -lobjc ",
"localedir"=>"/usr/local/share/locale", "rubyw_install_name"=>"",
"EXTOUT"=>".ext", "ECHO_C"=>"", "OBJDUMP"=>"",
"arch"=>"powerpc-darwin8.10.0", "MAJOR"=>"1", "ruby_version"=>"1.8",
"CC"=>"gcc", "EGREP"=>"/usr/bin/grep -E", "COMMON_HEADERS"=>"",
"COMMON_MACROS"=>"", "PACKAGE_TARNAME"=>"", "build_cpu"=>"powerpc",
"build_vendor"=>"apple", "host_alias"=>"", "RANLIB"=>"ranlib",
"LDSHARED"=>"cc -dynamic -bundle -undefined suppress -flat_namespace",
"LIBRUBYARG_SHARED"=>"-lruby", "YFLAGS"=>"",
"htmldir"=>"/usr/local/share/doc/$(PACKAGE)", "MINOR"=>"8",
"INSTALL_SCRIPT"=>"/usr/bin/install -c", "EXPORT_PREFIX"=>"",
"LIBRUBY_ALIASES"=>"libruby.1.8.dylib libruby.dylib", "LDFLAGS"=>"",
"datadir"=>"/usr/local/share", "NM"=>"",
"includedir"=>"/usr/local/include", "infodir"=>"/usr/local/share/info",
"host_os"=>"darwin8.10.0", "build"=>"powerpc-apple-darwin8.10.0",
"host"=>"powerpc-apple-darwin8.10.0", "INSTALL_DATA"=>"/usr/bin/install
-c -m 644", "build_os"=>"darwin8.10.0", "DLDFLAGS"=>"",
"ruby_install_name"=>"ruby", "DLEXT"=>"bundle",
"LIBRUBY_SO"=>"libruby.1.8.6.dylib", "TEENY"=>"6", "CPP"=>"gcc -E",
"ALLOCA"=>"$(LIBOBJDIR)alloca.o", "sysconfdir"=>"/usr/local/etc",
"exec_prefix"=>"/usr/local", "PATH_SEPARATOR"=>":", "LIBEXT"=>"a",
"mandir"=>"/usr/local/share/man", "libdir"=>"/usr/local/lib",
"build_alias"=>"", "target_cpu"=>"powerpc", "ECHO_N"=>"-n",
"sharedstatedir"=>"/usr/local/com", "YACC"=>"bison -y",
"configure_args"=>" '--prefix=/usr/local' '--enable-pthread'
'--with-readline-dir=/usr/local' '--enable-shared'", "SOLIBS"=>"",
"host_vendor"=>"apple", "TRY_LINK"=>"", "PACKAGE_STRING"=>"",
"target_os"=>"darwin8.10.0", "oldincludedir"=>"/usr/include",
"CP"=>"cp", "SET_MAKE"=>"", "LIBRUBYARG_STATIC"=>"-lruby-static",
"LIBRUBYARG"=>"-lruby", "RUBYW_INSTALL_NAME"=>"", "PACKAGE_NAME"=>"",
"pdfdir"=>"/usr/local/share/doc/$(PACKAGE)", "EXTSTATIC"=>"",
"ECHO_T"=>"", "RPATHFLAG"=>"", "SHELL"=>"/bin/sh", "STATIC"=>"",
"ASFLAGS"=>"", "INSTALL"=>"/usr/bin/install -c",
"sitearchdir"=>"/usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.10.0",
"STRIP"=>"strip -A -n", "ARCHFILE"=>"",
"LIBRUBY_DLDFLAGS"=>"-install_name /usr/local/lib/libruby.dylib
-current_version 1.8.6 -compatibility_version 1.8", "OBJEXT"=>"o",
"XLDFLAGS"=>" -L.", "LIBRUBY_LDSHARED"=>"cc -dynamiclib -undefined
suppress -flat_namespace", "ENABLE_SHARED"=>"yes", "RM"=>"rm -f",
"CCDLFLAGS"=>" -fno-common", "setup"=>"Setup", "CPPOUTFILE"=>"-o
conftest.i", "topdir"=>"/usr/local/lib/ruby/1.8/powerpc-darwin8.10.0",
"RUBY_SO_NAME"=>"ruby", "CFLAGS"=>"-g -O2 -fno-common -pipe
-fno-common", "localstatedir"=>"/usr/local/var", "LIBPATHFLAG"=>"
-L\"%s\"", "bindir"=>"/usr/local/bin",
"sitelibdir"=>"/usr/local/lib/ruby/site_ruby/1.8",
"NROFF"=>"/usr/bin/nroff", "CPPFLAGS"=>"",
"INSTALL_PROGRAM"=>"/usr/bin/install -c", "PACKAGE_BUGREPORT"=>"",
"libexecdir"=>"/usr/local/libexec", "OUTFLAG"=>"-o ",
"LIBRUBY_A"=>"libruby-static.a", "PREP"=>"miniruby", "ARCH_FLAG"=>""}\\

Maybe try a plain setup.rb installer for Hpricot?

trying this next..
 
S

Sergio Ruiz

Maybe try a plain setup.rb installer for Hpricot?

http://code.whytheluckystiff.net/dist/hpricot-0.6.tgz

_why

trying this, too..

not sure what you mean by a plain setup.rb installer..

i downloaded the tgz file.. but i can't seem to find setup.rb..

one thing to note, i did install rails using this:

http://hivelogic.com/narrative/articles/ruby-rails-mongrel-mysql-osx

which recompiles a new ruby.. but everything looks okay here:

ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [powerpc-darwin8.10.0]
 
J

John Joyce

could be a PATH issue.
make sure it's installing to the right Ruby.
If you used the Hivelogic method to install stuff, you will still
have the old broken Ruby on your system.
Also if you've installed anything else (Python for example) your path
might have changed.
there is also a gem path, but I don't recall the details, check the
docs at rubygems.org
 
S

Sergio Ruiz

John said:
could be a PATH issue.
make sure it's installing to the right Ruby.
If you used the Hivelogic method to install stuff, you will still
have the old broken Ruby on your system.
Also if you've installed anything else (Python for example) your path
might have changed.
there is also a gem path, but I don't recall the details, check the
docs at rubygems.org

hmm...

i installed the hivelogic stuff.. built ruby, and put it in
/usr/local/bin..

i just checked, and the old broken ruby is at /usr/bin

checking more into this..

and btw.. i do have python installed..

thanks!
 
J

John Joyce

hmm...

i installed the hivelogic stuff.. built ruby, and put it in
/usr/local/bin..

i just checked, and the old broken ruby is at /usr/bin

checking more into this..

and btw.. i do have python installed..

thanks!
Well, I posted on my own blog a few weeks ago, some software likes to
use a different one of the various dot files (.profile, .bash_login,
etc...)
And when they do, you sometimes get trouble with the path variable
generated. The different files all have a different precedence,
sometimes a murky one. The best solution is to install whatever you
need to install, then go and look in your home directory for any new
dot files. Open any new dot files and inspect the path stuff. Adjust
your preferred dot file with the new path info in the order you like,
then comment out the stuff in the dot file you don't want to use.
Leave a comment saying what was installed, and why it was commented
out, then you have it if you need it ever to uninstall something.

Sometimes lots of complex stuff all balances very delicately on the
PATH alone!
 
M

mortee

Again replying to myself:

After a lot of experimentation, I concluded that my problems are caused
by the fact that the Tiger version of the One Click Installer (rubyosx)
does assume an intel CPU at multiple spots, thus native extensions fail
to build on a ppc platform. Now I can successfully require hpricot on
that box.

It seems to be a mostly unrelated issue that my script crashes at random
points with segmentation fault. This seems to me a ruby interpreter
issue (it crashes e.g. in erb code, not only in the compiled hpricot
extension).

mortee
 
R

Ryan Davis

$ ruby -rubygems -rhpricot -e ''
ruby: no such file to load -- hpricot (LoadError)

That won't work anyways. Do this instead:

ruby -rubygems -e 'require "hpricot"'

'ruby -rubygems' does load rubygems but '-r' bypasses the regular
require so it won't work for installed gems. You have to use
'require' for that directly. We are talking to core about making -r
call require properly so things like rubygems can affect it.
 
J

Julian Tarkhanov

I concluded that my problems are caused
by the fact that the Tiger version of the One Click Installer
(rubyosx)
does assume an intel CPU at multiple spots

That's a good one of theirs indeed.
 
S

Sergio Ruiz

Sometimes lots of complex stuff all balances very delicately on the
PATH alone!

okay, i think i fixed this..

WHEW..

here's the scoop..

a week ago, i put a new hard drive and optical drive in my powerbook (i
do NOT recommend this to anyone who values their sanity whatsoever)..
reinstalled osx.. and set up the whole machine for development..

BUT..

i forgot to chmod +x .bash_profile

i did that..

and everything now works as it should..

dangit..

thanks for all your help!
 
S

Sergio Ruiz

Oh no! Let me guess... you were running /usr/bin/ruby instead of
/usr/local/bin/ruby?

it looks like i was running the correct ruby.. i think the paths were
just all messed up when it came to finding all the pieces to the gem..

thanks for all the help everyone!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top