Ruby Gem Nokogiri没有在Rails上安装3.2.11

时间:2017-10-27 14:04:06

标签: ruby rubygems

我正在尝试通过使用Rails 3.2.11 Docker 运行Rails应用。我运行bundle install时未安装宝石 nokogiri

我在我的Gemfile中有这个:

gem 'nokogiri', '~> 1.6.8.rc2'

这在我的LOCK文件中:

nokogiri (1.6.8.rc2)
      mini_portile2 (~> 2.1.0)

当我尝试通过docker运行bundle install时,收到以下错误消息:

************************************************************************
Extracting libxml2-2.9.3.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3... OK
Running 'configure' for libxml2 2.9.3... OK
Running 'compile' for libxml2 2.9.3... ERROR, review
'/var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3/compile.log'
to see what happened. Last lines are:
========================================================================
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash
/var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3/libxml2-2.9.3/missing
aclocal-1.15 -I m4
/var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3/libxml2-2.9.3/missing:
line 81: aclocal-1.15: command not found
WARNING: 'aclocal-1.15' is missing on your system.
         You should only need it if you modified 'acinclude.m4' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'aclocal' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>
make: *** [aclocal.m4] Error 127
========================================================================
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/ruby1.9.1
        --help
        --clean
        --use-system-libraries
        --enable-static
        --disable-static
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib
        --enable-cross-build
        --disable-cross-build
/var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:366:in `block
in execute': Failed to complete compile task (RuntimeError)
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in
`chdir'
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in
`execute'
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:111:in
`compile'
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:150:in
`cook'
        from extconf.rb:288:in `block (2 levels) in process_recipe'
        from extconf.rb:181:in `block in chdir_for_build'
        from extconf.rb:180:in `chdir'
        from extconf.rb:180:in `chdir_for_build'
        from extconf.rb:287:in `block in process_recipe'
        from extconf.rb:186:in `tap'
        from extconf.rb:186:in `process_recipe'
        from extconf.rb:477:in `<main>'


Gem files will remain installed in /var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2 for
inspection.
Results logged to /var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/gem_make.out

An error occurred while installing nokogiri (1.6.8.rc2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.8.rc2'` succeeds before bundling.

In Gemfile:
  fog was resolved to 1.23.0, which depends on
    nokogiri

我尝试过几次修改Gem文件,但它导致Nokogiri无法正常安装。

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

确保您的计算机上安装了libxml2。是否可以使用brew installapt-get install进行安装,具体取决于您的操作系统。

更新:如果您尝试在docker容器内运行应用程序,也可以添加libxml2并在Dockerfile中安装带RUN gem install nokogiri -v '1.6.8.1'的nokogiri