为什么heroku不能使用ruby 1.9.2在竹堆上安装nokogiri 1.6.5?

时间:2014-12-27 18:58:52

标签: ruby-on-rails heroku

在我的笔记本电脑上,我的红宝石版本是:

$ ruby -version
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-darwin14.0.0]

我的rails版本是:

$ ./bin/rails -v
Rails 3.2.15

我的Gemfile有一个对nokogiri的无版引用:

$ grep nokogiri Gemfile
gem "nokogiri"

但是我的Gemfile.lock显示了这个:

nokogiri (1.6.5)
  mini_portile (~> 0.6.0)

我在遗产竹堆上:

$ heroku info | grep -i stack
Stack:         bamboo-mri-1.9.2

当我推送到heroku时(使用git-ssh传输):

$ git push heroku master

部署炸弹到达nokogiri依赖时:

   ...
   Installing nokogiri (1.6.5) with native extensions /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

   /usr/ruby1.9.2/bin/ruby extconf.rb 
   *** 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/ruby1.9.2/bin/ruby
    --help
    --clean
   /usr/ruby1.9.2/lib/ruby/1.9.1/mkmf.rb:445:in `try_compile': wrong number of arguments (3 for 2) (ArgumentError)
    from extconf.rb:77:in `block in add_cflags'
    from /usr/ruby1.9.2/lib/ruby/1.9.1/mkmf.rb:481:in `with_cflags'
    from extconf.rb:76:in `add_cflags'
    from extconf.rb:323:in `<main>'
   checking if the C compiler accepts ... 

   Gem files will remain installed in /tmp/build_8908ccf0104d2f6073466c3fe2186d76/.bundle/gems/ruby/1.9.1/gems/nokogiri-1.6.5 for inspection.
   Results logged to /tmp/build_8908ccf0104d2f6073466c3fe2186d76/.bundle/gems/ruby/1.9.1/gems/nokogiri-1.6.5/ext/nokogiri/gem_make.out
    from /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:486:in `block in build_extensions'
    from /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:446:in `each'
    from /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:446:in `build_extensions'
    from /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:198:in `install'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/source.rb:95:in `install'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/installer.rb:55:in `block in run'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `block in each'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/installer.rb:44:in `run'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/installer.rb:8:in `install'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/cli.rb:225:in `install'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor.rb:246:in `dispatch'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor/base.rb:389:in `start'
    from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/bin/bundle:13:in `<top (required)>'
    from /usr/ruby1.9.2/bin/bundle:19:in `load'
    from /usr/ruby1.9.2/bin/bundle:19:in `<main>'
   FAILED: http://devcenter.heroku.com/articles/bundler

!     Push failed: failed to install gems via Bundler
!     If the problem persists, see http://help.heroku.com and provide Request ID 6f60ac09-059f-4a33-b913-02e32e2f34e4.

知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

nokogiri 1.6.5是最新版本。 nokogiri的新版本可能不支持在Bamboo堆栈中安装的nokogiri依赖项和C库。不要忘记竹堆已经快4岁了。

你假装不到一个月前发布的一个库来编译4年前发布的C库。 {/ 1}}错误可能是由于nokogiri所需的一个C库的公共方法签名发生变化而引起的。 nokogiri期望该方法接受3个参数,而旧版本的C库只接受2个。

您可以尝试将nokogiri要求降级为旧版本。

wrong number of arguments

实际上,最好的解决方案是升级到Cedar堆栈。在任何情况下,您最终都需要,Bamboo堆栈将在几个月后退役,您的应用程序将无论如何都将停止工作。