0

I'm trying to get the Ruby gem "Nokogiri" running on a Solaris machine where I don't have root priviledges. What I've done so far:

  • I've build my own ruby version (1.9.2p180) in my home directory
  • tried to install nokogiri with "gem install nokogiri"

The gem install then throwed this error:

Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

/home/bender/ruby/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.

So I downloaded and build the libiconv in /home/myuser/work/libiconv

$ ls /home/myuser/work/libiconv/
bin      build    include  lib      share

And passed the locations as arguments for nokogiri:

gem install nokogiri -- --with-iconv-dir=/home/myuser/work/libiconv --with-iconv-include=/home/myuser/work/libiconv/include --with-iconv-lib=/home/myuser/work/libiconv/lib 

Now the gem builds and no errors are displayed. The problem is, when I now try to use it, e.g. in irb it somehow fails to load:

require 'nokogiri'
LoadError: ld.so.1: ruby: fatal: libiconv.so.2: open failed: No such file or directory - /home/myuser/ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.so
    from /home/myuser/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/myuser/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/myuser/ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.4/lib/nokogiri.rb:13:in `<top (required)>'
    from /home/myuser/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:57:in `require'
    from /home/myuser/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:57:in `rescue in require'
    from /home/myuser/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from (irb):1
    from /home/myuser/ruby/bin/irb:12:in `<main>'

But when I look for the file which should be missing it is there and also readable/executable:

ll /home/myuser/ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.4/lib/nokogiri/
total 66
...
-rwxr-xr-x   1 myuser   group      370552 Jun  6 22:53 nokogiri.so
...

Ok, and that is where I'm stuck.. the file is there but can't be opened? I tried to rebuild the libiconv which had no effect. Nokogiri doesn't throw any error that the build process fails. So I don't know how to solve this and google could't give me answers either. I hope somebody here can give me some hints.

/edit

I googled around some more and found this post where somebody uses ldd to show dependencies. When I do the same for nokogiri it says:

ldd /home/myuser/ruby/bin/nokogiri
ldd: /home/myuser/ruby/bin/nokogiri: unsupported or unknown file type

I guess this is because its a ruby file but in case it is relevant I want to mention it.

2 Answers 2

0

If you're using GNU binutils, then try to set

LDFLAGS="-Wl,-rpath /home/myuser/work/libiconv/lib"

if it's a Solaris linker, then it's something like -X, I don't really remember. Just check the man page of ld for runpath settings. It'll allow the run-time linker to find the .so.

2
  • I'm not sure if I understood it right. I've searched the solaris ld manpage and found as option "-R", the manpages says: "A colon-separated list of directories used to specify library search directories to the runtime linker.". It seems to me that this is the option you meant, set LDFLAGS to "-R /home/myuser/work/libiconv/lib" and build libiconv and the nokogiri gem from scratch. Unfortunately the error remains. ( LoadError: ld.so.1: ruby: fatal: libiconv.so.2: open failed: No such file or directory - /home/myuser/ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.so )
    – andreas
    Jun 7, 2011 at 10:54
  • Well, you're compiling with gcc, probably, so you will probably need to set LDFLAGS='-Wl,-R -Wl,/some/path' . The gcc calls the Solaris ld with the parameters which follow -Wl, . I think that in my time (like 14 years ago), it was like -Xlinker -R -Xlinker /some/path
    – Roman
    Jun 7, 2011 at 20:39
0

If you're going to build your own sandbox, why not use RVM to do all the heavy lifting? Its purpose in life is to create a user sandbox in ~/.rvm, build and manage the Ruby versions you want to run and the gemsets associated with your projects.

If you decide to go that path, which I recommend highly, be sure to follow the single-user installation directions on the linked page, to add the appropriate string to your ~/.bash_profile or ~/.bashrc if you you don't use a *profile file, and follow the recommendations RVM outputs when you run rvm notes.

I have it installed on several Centos, Ubuntu and Mac OS boxes where I do development, and think it's great.

2
  • I'm using rvm without problems on my local machine (ubuntu), but on that solaris server it fails to install with: Installing RVM to /home/bender/.rvm/awk: syntax error near line 1 awk: bailing out near line 1 /home/myuser/.rvm/src/rvm/scripts/functions/installer: line 364: cp: No such file or directory I googled for that problem and found a gist (but unfortunately without solution here) here: gist.github.com/921374 and some japanese stuff here: d.hatena.ne.jp/murase_syuka/20101002/1286028764 , which I don't understand. :S
    – andreas
    Jun 7, 2011 at 8:54
  • I'd recommend bouncing it off the author. You can get his email address using rvm -v. Jun 7, 2011 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.