【问题标题】:Rails: error while installing rubyracerRails:安装 ruby​​racer 时出错
【发布时间】:2013-03-27 11:46:46
【问题描述】:

我正在我的 linode 服务器上运行“捆绑安装”。但无法安装rubyracer的原因。捆绑安装输出是:

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
*** 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
/usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0/ext/v8/build.rb:50:in `build_with_rubygem_libv8': undefined local variable or method `libv8_include_flags' for main:Object (NameError)
from extconf.rb:20:in `<main>'


Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0 for inspection.
Results logged to /usr/local/lib/ruby/gems/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.

实际上 gem ruby​​racer 已安装,但版本是 0.11.4。我只是不知道为什么它不采用这个版本并且只接受 0.11.0。

还有如何安装 0.11.0。当我运行错误“gem install therubyracer -v '0.11.0'”中给出的命令时,它无法执行并给出:

Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
ERROR: Failed to build gem native extension.

    /usr/local/bin/ruby extconf.rb
checking for main() in -lpthread... yes
*** 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
/usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0/ext/v8/build.rb:50:in    `build_with_rubygem_libv8': undefined local variable or method `libv8_include_flags' for    main:Object (NameError)
from extconf.rb:20:in `<main>'


Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-    0.11.0 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0/ext/v8/gem_make.out

这里有人可以帮忙吗?在堆栈和 git 上搜索了很多,但没有一个给定的解决方案有效。

我的宝石文件:

source 'https://rubygems.org'

gem 'rails', '3.2.12'
gem "paperclip"
gem 'mysql2'
gem "devise"
group :assets do
 gem 'sass-rails',   '~> 3.2.3'
 gem 'coffee-rails', '~> 3.2.1'

gem 'uglifier', '>= 1.0.3'
end


gem 'jquery-rails'
gem 'libv8', '3.11.8.4', :platform => :ruby
gem 'therubyracer', '0.11.0', :platforms => :ruby
gem 'rails_admin'
gem 'unicorn'
gem 'delayed_job_active_record'
gem 'daemons'

【问题讨论】:

  • Linux 或 windows 在哪个平台上?您使用的是哪个操作系统?
  • @SumitMunot linux。操作系统是 ubuntu 12
  • 你能把你的gemfile贴在这里吗?
  • 好的,尝试在你的 gemfile 中包含 gem 'execjs' 并运行 bundle update 命令。

标签: ruby-on-rails-3 rubygems therubyracer


【解决方案1】:

我在 ubuntu 上遇到了同样的问题:

经过一些实验,我能够确认命令行上的“gem install therubyracer --pre”工作正常,但告诉捆绑程序使用 --pre 选项不起作用:

bundle config build.therubyracer --pre

我不知道这是否是因为 gem 是通过依赖项而不是通过 Gemfile 中的显式“gem”行引入的。即使经过大量的谷歌搜索,我也无法解决这个问题,但由于 0.11 似乎只有几个小时,我决定尝试通过添加以下内容恢复到以前的 0.10 版本:

gem 'therubyracer', '=0.10'

在使用依赖它的 gem 之前。这迫使捆绑器选择较早的版本,并像魅力一样安装。希望尽快someone will fix 0.11

在 github 上查看 therubyracer 的问题后,这似乎与两个不同的问题有关 - 一个已关闭:https://github.com/cowboyd/therubyracer/issues/213 建议首先(或显式)安装 libv8 gem,这会导致不同的错误:https://github.com/cowboyd/therubyracer/issues/215这还没有关闭——libv8 gem 中似乎有一个损坏的二进制文件,用于 64 位目标。唯一的解决方案似乎是从源代码构建 libv8 或像我一样做并备份到 0.11beta8 或更早版本(有人说0.11beta8 有效)。在此之前,我建议您在 Github 上观看 215 问题并等待修复。

谢谢。

【讨论】:

  • 嘿,gem install therubyracer --pre 在这里不起作用。给出错误:安装 ruby​​racer 时出错:错误:无法构建 gem 原生扩展。
  • 在你的 gemfile 中指定 gem 的版本,同时在你的系统上安装 'therubracer' gem 的依赖项。
  • 你的意思是我应该安装 libv8 并将 gemfile 修改为 'gem 'therubyracer', :require => 'v8', :platforms => :ruby' 而不是 'gem 'libv8', '3.11。 8.4', :platform => :ruby gem 'therubyracer', '0.11.0', :platforms => :ruby'?
  • 做到了,但同样的错误。它不断给出“安装rubyracer(0.11.0)时发生错误,并且Bundler无法继续。确保gem install therubyracer -v '0.11.0'在捆绑之前成功。”
【解决方案2】:

问题是由于多个 libv8 版本造成的。

解决方案:卸载 libv8 并运行你的包。 命令:

1) gem 卸载 libv8 2) 捆绑

【讨论】:

    【解决方案3】:

    这也是由于与 libv8 的一些冲突而发生的,尽管您只需为 ruby​​racer 分配一个版本,它就会被安装:

    在 gemfile 中更改以下内容:

    gem 'therubyracer', '~> 0.12.1'

    并进行捆绑安装

    如果这也不能解决问题,那么 libv8 存在一些问题。手动安装以下 gem:

    gem install rmagick -v '2.13.2' 如果没有安装,请通过 brew 安装 imagemagick gem install libv8 -v 3.11.8.17 -- --with-system-v8 在 gemfile 中更改以下内容: gem 'therubyracer', '~> 0.12.1'

    然后进行捆绑安装。

    【讨论】:

      猜你喜欢
      • 2017-06-24
      • 1970-01-01
      • 2015-10-04
      • 2014-10-02
      • 2022-10-05
      • 2014-01-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多