Real Trouble Trying To Install Gem with Native Ext

Hi all,

So I’ve been pushing through to get pauldix-feedzirra working on my account but it requires libxslt, which isn’t installed in a way that I can compile a gem with.

So I downloaded libxslt and compiled/installed it successfully in my account. It is nokogiri as a dependency to pauldix-feedzirra that complains it can’t find it first, so I simply (after a lot of digging) go into my .gem/gems/nokogiri-1.2.3/ext/nokogiri directory and run with my locally compiled path to libxslt:

"ruby extconf.rb --with-xslt-dir=/home/username/run --prefix=/home/username/.gem/gems and IT COMPILES!

Sadly, this doesn’t fix it though. When I try to run gem install pauldix-feedzirra again, it doesn’t recognize that nokogiri is installed and writes over the old directory, giving me the same error i was getting when it wasn’t compiled. :frowning:

I don’t know if:

A.) the nokogiri gem isn’t getting installed into the right place?
B.) there’s some way to inform the gem install of where those dependencies are (libxslt custom location, etc.) though I haven’t found any options for the gem install command that would do that.

ANY HELP!?!? I really need to get this native code usin’ gem installed.

Thanks all!

hi there.

just figured this out.
to install nokogiri, you need to first install the xslt package (make them yourself in your local directory) and then after that, pass in the right parameters that point the gem installer to the right xslt package.

  1. get the package for that library -> download the xslt library that you need

  2. in dreamhost do: wget the-ftp-url-from-above

  3. decide where to put it and do a ./configure --prefix=/path-where-you-want-to-put-it/

  4. make

  5. make install

  6. gem install nokogiri – --with-xslt-include=/path-where-you-want-to-put-it/include/ --with-xslt-lib=/path-where-you-want-to-put-it/lib/

mrfiocco: thanks for the details! this looks like the approach i was taking but i don’t remember the details. i’ll post my results here. this seems like a rarely documented (but important) task on dreamhost!

thanks again.

Hi mrfiocco,

This worked great. (I think it was the ‘–’ after the install command i was missing.) I was trying to install a gem with multiple other dependencies that required native extensions but I was able to use this method for each of them, downloading them one by one into my home directory, compiling/installing them and then eventually, when all dependencies of the master gem were satisfied, I was able to run the gem install for that successfully.

Now I just need to navigate all the crap about Passenger not recognizing the local GEM environment and I’ll be all set. :slight_smile:

Thanks again.

Thanks, Mr Fiocco.

I fumbled myself along to this same point using bits of other threads about getting libxslt on Dreamhost.

I’ve got it in the right places, namely
/home/myusername/local/lib and /home/myusername/local/include,
but running the same command as you provided fails:

[gravano]$ gem install nokogiri – --with-xslt-include=/home/myusername/local/include/ --with-xslt-lib=/home/myusername/local/lib/
Building native extensions. This could take a while…
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb --with-xslt-include=/home/myusername/local/include/ --with-xslt-lib=/home/myusername/local/lib/
checking for iconv.h in /home/myusername/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2,/usr/include,/usr/include/libxml2… yes
checking for libxml/parser.h in /home/myusername/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2,/usr/include,/usr/include/libxml2… yes
checking for libxslt/xslt.h in /home/myusername/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2,/usr/include,/usr/include/libxml2… yes
checking for libexslt/exslt.h in /home/myusername/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2,/usr/include,/usr/include/libxml2… yes
checking for xmlParseDoc() in -lxml2… yes
checking for xsltParseStylesheetDoc() in -lxslt… no
libxslt is missing. try ‘port install libxslt’ or ‘yum install libxslt-devel’

But it is not missing. It says it found the header, right? libxslt/xslt.h

I tried reconfiguring and making libxslt, but I’m not sure what is the missing link here.


I tried what you did with “ruby extconf.rb” and also was able to compile nokogiri, but had the same problem with feedzirra not finding it.

I also was able to get nokogiri installed. I had the xsltstylesheet problem someone else was having but I just got the latest version of libxslt, compiled it, and then I installed nokogiri. I installed two versions. Here’s the one no one is mentioning:

l$ gem install tenderlove-nokogiri – --with-xslt-include=/home/user/local/include/ --with-xslt-lib=/home/user/local/lib/
Successfully installed tenderlove-nokogiri-
1 gem installed

But when i open the ruby console and check if it is working I get this problem:


LoadError: /home/user/.gem/ruby/1.8/gems/nokogiri-1.2.3/lib/nokogiri/ cannot open shared object file: No such file or directory - /home/user/.gem/ruby/1.8/gems/nokogiri-1.2.3/lib/nokogiri/
from /home/user/.gem/ruby/1.8/gems/nokogiri-1.2.3/lib/nokogiri/
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in require' from /home/user/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:inrequire’
from /home/user/.gem/ruby/1.8/gems/nokogiri-1.2.3/lib/nokogiri.rb:6
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:inrequire’
from /home/user/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require’
from (irb):1

But I check to see if I have that file and it is there:

$ ls -la /home/user/.gem/ruby/1.8/gems/nokogiri-1.2.3/lib/nokogiri/
-rwxr-xr-x 1 user pg1585848 793114 May 18 2009 /home/user/.gem/ruby/1.8/gems/nokogiri-1.2.3/lib/nokogiri/

Any ideas?!

Here’s your problem:

[code]$ file /home/user/.gem/ruby/1.8/gems/nokogiri-1.2.3/lib/nokogiri/
/home/user/.gem/ruby/1.8/gems/nokogiri-1.2.3/lib/nokogiri/ ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), not stripped

$ uname -m
[/code]It looks like you’ve got an old 32-bit gem on a 64-bit system. Get a 64-bit copy of the nokogiri gem and things should go better…

I’ve gone through this post over and over but still have problems. ‘ryanrockets’ has the same problem as I have (posted 10/17/09). Specifically I get this (abbreviated) output when running gem install:

checking for xmlParseDoc() in -lxml2… yes
checking for xsltParseStylesheetDoc() in -lxslt… no
libxslt is missing. try ‘port install libxslt’ or ‘yum install libxslt-devel’
*** extconf.rb failed ***

I do this setup:

mkdir $ROOT
cd $ROOT
tar xvf libxml2-2.7.7.tar.gz
tar xvf libxslt-1.1.26.tar.gz
cd $ROOT/libxml2-2.7.7
nice ./configure --prefix=$ROOT --without-python
nice make
nice make install
cd $ROOT/libxslt-1.1.26
nice ./configure --prefix=$ROOT --with-libxml-prefix=$ROOT --without-python
nice make
nice make install

And then these both fail as indicated above:

gem install nokogiri – --with-xslt-include=$ROOT/include --with-xslt-lib=$ROOT/lib

cd $HOME/.gem/gems/nokogiri-1.4.1/ext/nokogiri
ruby extconf.rb --with-xslt-dir=$HOME/local --prefix=$HOME/.gem/gems

Have I failed to setup something else?
Am I using incompatible versions of these libraries?
Am I missing some non explicit detail in the previous posts?

I’ve been looping on this all day and ran these scripts in a new user account that I created to make sure I had a clean environment. My .bashrc and .bash_profile have these lines:

export GEM_HOME=$HOME/.gem
export GEM_PATH=$GEM_HOME:/usr/lib/ruby/gems/1.8
export PATH=$HOME/.gems/bin:$PATH
export PATH=$HOME/local/bin:$PATH

Help appreciated, thanks, Jim

I resolved the build issue. I needed to pick up both libxml2-dev and libxslt1-dev (not libxml2 and libxslt). The following script appears to work:



mkdir $ROOT
cd $ROOT

libxml2-2.7.7 does not work, need libxml2-dev

libxslt-1.1.26 does not work, need libxslt1-dev

Get libxml2-dev

tar xvf libxml2_2.6.32.dfsg.orig.tar.gz


tar xvf libxslt_1.1.24.orig.tar.gz

cd $ROOT/libxml2-2.6.32
nice ./configure --prefix=$ROOT --without-python
nice make
nice make install

cd $ROOT/libxslt-1.1.24
nice ./configure --prefix=$ROOT --with-libxml-prefix=$ROOT --without-python
nice make
nice make install

gem install nokogiri – --with-xslt-include=$ROOT/include --with-xslt-lib=$ROOT/lib

I am still wrangling with GEM_PATH and such to get my scripts and passenger deployment running, but thought I’d post the above before I move on.