Gem :: Ext :: BuildError:错误:无法构建gem原生扩展--Ubuntu

时间:2016-05-25 15:00:24

标签: ruby-on-rails ruby rubygems

每当我在DigitalOcean Droplet上尝试bundle install时,ruby-rails-postgres-nginx-unicorn

我后来使用终端

中的SSH安装了mongodb

以及稍后将项目上传到/ home //文件夹并捆绑安装时,我收到此错误。

Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
vinod@ruby-rails-postgres-nginx-unicorn-512mb-sgp1-01:~/dride$ bundle 
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 11.1.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.9.0
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.5.2
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using nokogiri 1.6.7.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using loofah 2.0.3
Using rails-html-sanitizer 1.0.3
Using actionview 4.2.5.2
Using rack 1.6.4
Using rack-test 0.6.3
Using actionpack 4.2.5.2
Using globalid 0.3.6
Using activejob 4.2.5.2
Using mime-types-data 3.2016.0521
Using mime-types 3.1
Using mail 2.6.4
Using actionmailer 4.2.5.2
Using activemodel 4.2.5.2
Using arel 6.0.3
Using activerecord 4.2.5.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20160525-15401-ztxhbh.rb extconf.rb 
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling crypt_gensalt.c
compiling crypt.c
compiling crypt_blowfish.c
virtual memory exhausted: Cannot allocate memory
make: *** [crypt_blowfish.o] Error 1

make failed, exit code 2

Gem files will remain installed in /tmp/bundler20160525-15401-11lp2i/bcrypt-3.1.11/gems/bcrypt-3.1.11 for inspection.
Results logged to /tmp/bundler20160525-15401-11lp2i/bcrypt-3.1.11/extensions/x86_64-linux/2.2.0/bcrypt-3.1.11/gem_make.out
  

安装bcrypt(3.1.11)时发生错误,而Bundler则不能   继续。       在捆绑之前确保gem install bcrypt -v '3.1.11'成功。

我的gemfile是

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'mongoid', '~> 5.1.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
  gem "factory_girl_rails"
  gem 'ffaker'
  gem "shoulda-matchers"
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

group :test do
  gem "rspec-rails"
end

gem "devise"
  

已更新

当我尝试取消注释gem 'bcrypt', '~> 3.1.7'并再次运行bundle install时 我收到了这个错误。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20160525-19540-1s18rpw.rb extconf.rb 
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-unknown-linux-gnu/ports/libxml2/2.9.2... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0003-Stop-parsing-on-entities-boundaries-errors.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0004-Cleanup-conditional-section-error-handling.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0005-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0006-Another-variation-of-overflow-in-Conditional-section.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0007-Fix-an-error-in-previous-Conditional-section-patch.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0008-CVE-2015-8035-Fix-XZ-compression-support-loop.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0009-Updated-config.guess.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0010-Fix-parsering-short-unclosed-comment-uninitialized-access.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0011-Avoid-extra-processing-of-MarkupDecl-when-EOF.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0012-Avoid-processing-entities-after-encoding-conversion-.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0013-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0014-CVE-2015-5312-Another-entity-expansion-issue.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0015-Add-xmlHaltParser-to-stop-the-parser.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0016-Detect-incoherency-on-GROW.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0017-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0018-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0019-Do-not-print-error-context-when-there-is-none.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0020-xmlStopParser-reset-errNo.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0021-Reuse-xmlHaltParser-where-it-makes-sense.patch... OK
Running 'configure' for libxml2 2.9.2... OK
Running 'compile' for libxml2 2.9.2... ERROR, review '/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/compile.log' to see what happened. Last lines are:
========================================================================
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include/libxml'
make[3]: Entering directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include'
make[2]: Leaving directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include'
Making all in .
make[2]: Entering directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2'
  CC       SAX.lo
  CC       entities.lo
  CC       encoding.lo
  CC       error.lo
  CC       parserInternals.lo
  CC       parser.lo
virtual memory exhausted: Cannot allocate memory
make[2]: *** [parser.lo] Error 1
make[2]: Leaving directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2'
make: *** [all] Error 2
========================================================================
*** 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/local/rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
    --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
/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:366:in `block in execute': Failed to complete compile task (RuntimeError)
    from /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:337:in `chdir'
    from /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:337:in `execute'
    from /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:111:in `compile'
    from /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:150: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>'

extconf failed, exit code 1

Gem files will remain installed in /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /home/vinod/dride/vendor/bundle/ruby/2.2.0/extensions/x86_64-linux/2.2.0/nokogiri-1.6.7.2/gem_make.out
An error occurred while installing nokogiri (1.6.7.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.7.2'` succeeds before bundling.

1 个答案:

答案 0 :(得分:1)

当我增加记忆&amp;液滴大小从521MB到2GB,所有错误都消失了,对我有用。