在heroku安装therubyracer,无法构建gem原生扩展

Ala*_*ano 2 ruby ubuntu ruby-on-rails heroku

我一直在将Rails应用程序上传到Heroku时出错

Installing therubyracer (0.11.0)
       Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
       /usr/local/bin/ruby extconf.rb
       checking for main() in -lpthread... yes
       checking for v8.h... no
       *** 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/bin/ruby
       --with-pthreadlib
       --without-pthreadlib
       --enable-debug
       --disable-debug
       --with-v8-dir
       --without-v8-dir
       --with-v8-include
       --without-v8-include=${v8-dir}/include
       --with-v8-lib
       --without-v8-lib=${v8-dir}/lib
       /tmp/build_3srt9ifqtbs6m/vendor/bundle/ruby/1.9.1/gems/therubyracer-0.11.0/ext/v8/build.rb:42:in `build_with_system_libv8': unable to locate libv8. Please see output for details (RuntimeError)
       from extconf.rb:22:in `<main>'
       The Ruby Racer requires libv8 ~> 3.11.8
       to be present on your system in order to compile
       and link, but it could not be found.
       In order to resolve this, you will either need to manually
       install an appropriate libv8 and make sure that this
       build process can find it. If you install it into the
       standard system path, then it should just be picked up
       automatically. Otherwise, you'll have to pass some extra
       flags to the build process as a hint.
       If you don't want to bother with all that, there is a
       rubygem that will do all this for you. You can add
       following line to your Gemfile:
       gem 'libv8', '~> 3.11.8'
       We hope that helps, and we apologize, but now we have
       to push the eject button on this install.
       thanks,
       The Mgmt.
       Gem files will remain installed in /tmp/build_3srt9ifqtbs6m/vendor/bundle/ruby/1.9.1/gems/therubyracer-0.11.0 for inspection.
       Results logged to /tmp/build_3srt9ifqtbs6m/vendor/bundle/ruby/1.9.1/gems/therubyracer-0.11.0/ext/v8/gem_make.out
       An error occurred while installing therubyracer (0.11.0), and Bundler cannot continue.
       Make sure that `gem install therubyracer -v '0.11.0'` succeeds before bundling.
 !
 !     Failed to install gems via Bundler.
 !
 !     Heroku push rejected, failed to compile Ruby/rails app
Run Code Online (Sandbox Code Playgroud)

Gem文件的一部分

gem 'libv8', '~> 3.11.8'
gem "therubyracer", :platforms => :ruby, :require => 'v8'
group :linux_test do
  #gem "therubyracer", :require => false
  gem "libnotify", :require => false
end
group :production do
  gem "therubyracer-heroku"
  gem "pg"
end
Run Code Online (Sandbox Code Playgroud)

therubyracer并且lib8肯定是最新的,我刚刚重新安装它们.

我如何解决它?

PS Ubuntu 12.1,x64.

Mic*_*ley 6

查看Heroku Cedar上的Rails 3.1+资产管道,网址https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar:

therubyracer

如果您以前使用过therubyracer或者therubyracer-heroku,这些宝石不再需要,并且强烈建议不要使用这些宝石,因为这些宝石会占用大量内存.

如果您therubyracer在开发环境中需要gem,请将其包装在一个组中:

group :development do
  gem 'therubyracer', :platforms => :ruby, :require => 'v8'
end
Run Code Online (Sandbox Code Playgroud)

(Heroku不会安装只存在于development组中的宝石.)

无论如何,请从production下面的组中删除它.