开发者

nokogiri.so LoadError maybe problem with libiconv on Solaris

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 g开发者_Python百科uess this is because its a ruby file but in case it is relevant I want to mention it.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜