在Amazon AWS上安装的Ruby on Rails失败:由于某些原因无法创建Makefile,可能缺少必要的库和/或标题

时间:2016-01-23 16:10:23

标签: ruby-on-rails ruby amazon-web-services amazon-ec2

我发布这个问题,以便我可以自己回答这个问题,以便其他可能被卡住的人受益。我试图在Amazon AWS EC2实例上安装Rails并继续遇到同样的错误。我试着遵循Nokogiri指令here,我发现joelparkerhenderson的答案here非常有用,并按照他的指示行事,但仍然出现错误:

$ gem install nokogiri -- \
> --with-xml2-dir=/usr/include/libxml2 \
> --with-xslt-dir=/usr/include/libxslt
Building native extensions with: '--with-xml2-dir=/usr/include/libxml2 --with-xslt-dir=/usr/include/libxslt'
This could take a while...
ERROR:  Error installing nokogiri:
        ERROR: Failed to build gem native extension.

    current directory: /usr/local/share/ruby/gems/2.0/gems/nokogiri-1.6.7.2/ext/nokogiri
/usr/bin/ruby2.0 -r ./siteconf20160123-18643-1aqmthw.rb extconf.rb --with-xml2-dir=/usr/include/libxml2 --with-xslt-dir=/usr/include/libxslt
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.0.0
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
        - 0001-Revert-Missing-initialization-for-the-catalog-module.patch
        - 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch
        - 0003-Stop-parsing-on-entities-boundaries-errors.patch
        - 0004-Cleanup-conditional-section-error-handling.patch
        - 0005-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch
        - 0006-Another-variation-of-overflow-in-Conditional-section.patch
        - 0007-Fix-an-error-in-previous-Conditional-section-patch.patch
        - 0008-CVE-2015-8035-Fix-XZ-compression-support-loop.patch
        - 0009-Updated-config.guess.patch
        - 0010-Fix-parsering-short-unclosed-comment-uninitialized-access.patch
        - 0011-Avoid-extra-processing-of-MarkupDecl-when-EOF.patch
        - 0012-Avoid-processing-entities-after-encoding-conversion-.patch
        - 0013-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch
        - 0014-CVE-2015-5312-Another-entity-expansion-issue.patch
        - 0015-Add-xmlHaltParser-to-stop-the-parser.patch
        - 0016-Detect-incoherency-on-GROW.patch
        - 0017-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch
        - 0018-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch
        - 0019-Do-not-print-error-context-when-there-is-none.patch
        - 0020-xmlStopParser-reset-errNo.patch
        - 0021-Reuse-xmlHaltParser-where-it-makes-sense.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-redhat-linux-gnu/ports/libxml2/2.9.2... OK
*** 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}/lib64
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/ruby2.0
        --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
/usr/local/share/ruby/gems/2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:79:in `apply_patch': Failed to complete patch task; patch(1) or git(1) is required. (RuntimeError)
        from /usr/local/share/ruby/gems/2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:87:in `block in patch'
        from /usr/local/share/ruby/gems/2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:85:in `each'
        from /usr/local/share/ruby/gems/2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:85:in `patch'
        from /usr/local/share/ruby/gems/2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:148:in `cook'
        from extconf.rb:289:in `block (2 levels) in process_recipe'
        from extconf.rb:182:in `block in chdir_for_build'
        from extconf.rb:181:in `chdir'
        from extconf.rb:181:in `chdir_for_build'
        from extconf.rb:288:in `block in process_recipe'
        from extconf.rb:187:in `tap'
        from extconf.rb:187:in `process_recipe'
        from extconf.rb:478:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/local/lib64/ruby/gems/2.0/gems/nokogiri-1.6.7.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/share/ruby/gems/2.0/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /usr/local/lib64/ruby/gems/2.0/gems/nokogiri-1.6.7.2/gem_make.out

对我来说,关键线(以及砰的一声对着墙壁的时刻)是以下几行:

/usr/local/share/ruby/gems/2.0/gems/mini_portile2-2.0.0/lib/mi
  ni_portile2/mini_portile.rb:79:in `apply_patch': Failed to com
  plete patch task; patch(1) or git(1) is required. (RuntimeError)

我想我只是忽略了这一点,因为我太忙于搜索mkmf.log文件并查看其他人&#39;其他无关的Rails在线安装问题的答案。

1 个答案:

答案 0 :(得分:3)

对我而言,解决方案就像这样简单:

$ yum install git

之后,

$ gem install rails
像桃子一样工作,我得到了

$ rails --version
Rails 4.2.5

我希望这有助于其他人。