nokogiri.so LoadError 可能是 Solaris 上 libiconv 的问题

发布于 2024-11-14 03:56:01 字数 2840 浏览 0 评论 0原文

我正在尝试让 Ruby gem“Nokogiri”在我没有 root 权限的 Solaris 计算机上运行。到目前为止我所做的:

  • 我已经在我的主目录中构建了自己的ruby版本(1.9.2p180)
  • 尝试使用“gem install nokogiri”安装nokogiri

gem安装然后抛出了这个错误:

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.

所以我下载并构建了libiconv在 /home/myuser/work/libiconv 中

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

并将位置作为 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 

现在 gem 已构建并且不会显示任何错误。问题是,当我现在尝试使用它时,例如在 irb 中,它以某种方式无法加载:

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>'

但是当我查找应该丢失的文件时,它就在那里并且可读/可执行:

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
...

好的,这就是我所在的位置卡住了..文件在那里但无法打开?我尝试重建libiconv,但没有效果。 Nokogiri 不会抛出任何构建过程失败的错误。所以我不知道如何解决这个问题,谷歌也无法给我答案。我希望这里有人能给我一些提示。

/edit

我用谷歌搜索了更多内容,发现 这篇文章 有人使用 ldd 来显示依赖项。当我对 nokogiri 做同样的事情时,它说:

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

我想这是因为它是一个 ruby​​ 文件,但如果它是相关的,我想提及它。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寻找我们的幸福 2024-11-21 03:56:01

如果你使用的是 GNU binutils,那么尝试设置

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

它是否是 Solaris 链接器,然后是类似 -X 的东西,我不太记得了。只需检查 ld 的手册页以了解运行路径设置。它将允许运行时链接器找到.so。

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.

过度放纵 2024-11-21 03:56:01

如果您要构建自己的沙箱,为什么不使用 RVM 来完成所有繁重的工作?它的目的是在 ~/.rvm 中创建一个用户沙箱,构建和管理您想要运行的 Ruby 版本以及与您的项目关联的 gemset。

如果您决定走这条路(我强烈推荐),请务必遵循链接页面上的单用户安装说明,将适当的字符串添加到您的 ~/.bash_profile~/.bashrc 如果您不使用 *profile 文件,请在运行 rvm Notes 时遵循 RVM 输出的建议。

我将它安装在我进行开发的多个 Centos、Ubuntu 和 Mac OS 机器上,并且认为它很棒。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文