无法构建不同版本的gem原生扩展ruby racer gem

时间:2013-08-29 14:10:42

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 ruby-on-rails-3.2 rubygems

我从生产中复制了应用程序并进行了捆绑安装,以安装生产版本中缺少的所有宝石,而不是我本地机器上的宝石。

Gem.lock文件的rubyracer版本为“0.10.1”。因此,当它尝试使用bundle install安装此版本时会出现以下错误。

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/user/.rvm/rubies/ruby-1.9.3-p392/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=/home/user/.rvm/rubies/ruby-1.9.3-p392/bin/ruby                                                                                                                                                                                                               
extconf.rb:15:in `<main>': undefined method `include_path' for Libv8:Module (NoMethodError)                                                                                                                                                                                    


Gem files will remain installed in /home/user/.rvm/gems/ruby-1.9.3-p392/gems/therubyracer-0.10.1 for inspection.                                                                                                                                                             
Results logged to /home/user/.rvm/gems/ruby-1.9.3-p392/gems/therubyracer-0.10.1/ext/v8/gem_make.out      

由于此错误,我无法在本地计算机的生产版本的代码上运行脚手架命令。请帮帮我。

我们可以编辑gemfile.lock以删除“therubyracer(0.10.1)”,然后运行命令generate scaffold,然后在使用生成脚手架后放回更改吗?

编辑:

 *** 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=/home/vsadhu/.rvm/rubies/ruby-1.9.3-p392/bin/ruby
extconf.rb:14:in `<main>': undefined method `include_path' for Libv8:Module (NoMethodError)

1 个答案:

答案 0 :(得分:1)

回应以下引用:

  

我们可以编辑gemfile.lock来删除“therubyracer(0.10.1)”

不,我们不能。根据您所使用的操作系统,您可以执行以下操作:

$gem uninstall libv8 
$gem install therubyracer

我有一个我最近做过的rails应用程序,我也在运行Rails 3.2.14并且有以下内容:

group :assets do
  gem 'therubyracer', :require => 'v8'
  gem 'less-rails'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

在将此资产块添加到gemfile之前,请先使用第二种方法。 删除您的Gemfile.lock,然后将资产块添加到Gemfile,保存并运行bundle update