尝试安装 libv8 v3.11.8.9 时如何解决此问题?

Posted

技术标签:

【中文标题】尝试安装 libv8 v3.11.8.9 时如何解决此问题?【英文标题】:How do I resolve this issue when attempting to install libv8 v3.11.8.9? 【发布时间】:2012-12-19 11:45:36 【问题描述】:

libv8 gem(v3.3.10 之后的任何版本)的安装失败并显示消息“已终止”。

我的 Gemfile 中包含了 libv8 和 therubyracer:

group :production, :staging do
  gem 'libv8'
  gem 'therubyracer'
end

bundle update 在本地运行良好(Mac OS X)。当我执行cap staging deploy 时,部署失败并显示:

  * 2013-01-04 19:17:51 executing `bundle:install'
  * executing "cd /path/to/app/app-staging/releases/20130105001748 && bundle install --gemfile /path/to/app/app-staging/releases/20130105001748/Gemfile --path /path/to/app/app-staging/shared/bundle --deployment --quiet --without development"
    servers: ["staging.app.com"]
    [staging.app.com] executing command
 ** [out :: staging.app.com] bash: line 1:  4324 Killed                  bundle install --gemfile /path/to/app/app-staging/releases/20130105001748/Gemfile --path /path/to/app/app-staging/shared/bundle --deployment --quiet --without development
    command finished in 48980ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /path/to/app/app-staging/releases/20130105001748; true"
    servers: ["staging.app.com"]
    [staging.app.com] executing command
    command finished in 1928ms
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p327@app' -c 'cd /path/to/app/app-staging/releases/20130105001748 && bundle install --gemfile /path/to/app/app-staging/releases/20130105001748/Gemfile --path /path/to/app/app-staging/shared/bundle --deployment --quiet --without development'" on staging.app.com

如果我转到服务器(Linode 上的 Debian 6 32 位,Linux 3.5.2-linode45)并运行 bundle exec gem install libv8 -v '3.11.8.9',它会失败并显示:

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

        /usr/local/rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb
creating Makefile
Using compiler: /usr/bin/g++
g++: Internal error: Killed (program cc1plus)
Please submit a full bug report.
See <file:///usr/share/doc/gcc-4.4/README.Bugs> for instructions.
make[1]: *** [/path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/v8_base/src/api.o] Error 1
make: *** [ia32.release] Error 2
/path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
  from /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/ext/libv8/location.rb:35:in `each'
  from /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/ext/libv8/location.rb:35:in `verify_installation!'
  from /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/ext/libv8/location.rb:26:in `install!'
  from extconf.rb:7:in `<main>'
GYP_GENERATORS=make \
  build/gyp/gyp --generator-output="out" build/all.gyp \
                -Ibuild/standalone.gypi --depth=. \
                -Dv8_target_arch=ia32 \
                -S.ia32 -Dhost_arch=ia32
make[1]: Entering directory `/path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out'
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/allocation.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/bignum.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/bignum-dtoa.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/cached-powers.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/conversions.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/diy-fp.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/dtoa.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/fast-dtoa.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/fixed-dtoa.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/once.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/preparse-data.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/preparser.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/preparser-api.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/scanner.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/strtod.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/token.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/unicode.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/utils.o
  AR(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/tools/gyp/libpreparser_lib.a
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/preparser/preparser/preparser-process.o
  LINK(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/preparser
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/v8_base/src/accessors.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/v8_base/src/allocation.o
  CXX(target) /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out/ia32.release/obj.target/v8_base/src/api.o
make[1]: Leaving directory `/path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/vendor/v8/out'


Gem files will remain installed in /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9 for inspection.
Results logged to /path/to/app/app-staging/shared/bundle/ruby/1.9.1/gems/libv8-3.11.8.9/ext/libv8/gem_make.out

目前,我必须指定旧版本的 therubyracer 和 libv8 才能使我的部署成功:

group :production, :staging do
  gem 'libv8', '~> 3.3.10'
  gem 'therubyracer', '~> 0.10.2'
end

似乎this Issue 可能是相关的。

有解决办法吗?

【问题讨论】:

磁盘空间好像有问题。您可以尝试在digitalocean.com/community/tutorials/… 的帮助下进行交换。 【参考方案1】:

事情在 2013 年 1 月 7 日得到解决……但一天后一切又崩溃了。又过了一天,看起来事情又重新在一起了!

therubyracer v0.11.1 现在再次依赖于 libv8 gem。因此,我的 Gemfile 已更改为:

group :production, :staging do
  gem 'therubyracer'
end

这将安装最新版本的 therubyracer (v0.11.1) 以及最新版本的 libv8 (v3.11.8.13)。这已经完全解决了我的问题 - 因此,therubyracer v0.11.1 和 libv8 v3.11.8.13 gem 安装得很好。

如果您不是这种情况,那么仍有选择。对于仍然不会部署的 Rails 应用程序,我已经取得了成功:

group :production do
  gem 'libv8', '3.11.8.10'
  gem 'therubyracer'
end

也有可能(并且可能是更好的选择)只使用已知良好的版本,直到通过将 Gemfile 更改为:

group :production do
  gem 'therubyracer', '0.10.2'
end

【讨论】:

【参考方案2】:

如果您愿意,我只是将其作为替代答案,即“降低预期”

我昨天花了 4 个小时试图绕过这个 libv8-on-windows 的工作,结果我的一半以上的 gem 都在尝试要求它。我最终降低了我的期望,只是直接从 ruby​​ 运行我所需的 Windows 操作,根据需要加载 ActiveRecord 和 ActiveSupport gem 等。

我知道这不是一个好的答案,而且可能不是您想听到的。但是 windows 和 rails 似乎并没有很好地发挥作用。

【讨论】:

这个特定问题被隔离到某个版本范围,并且在 Debian Linux 上发生在我身上(它在我的本地 Mac OS 环境中运行良好)。我的特定问题/答案根本不涉及 Windows,但我并不真的不同意你(根据我所听到的)Windows 和 Rails 不能很好地协同工作。

以上是关于尝试安装 libv8 v3.11.8.9 时如何解决此问题?的主要内容,如果未能解决你的问题,请参考以下文章

如何使用预安装的 libv8 gem 和预编译的 v8 依赖项在 aarch64 上安装 therubyracer?

在安装了 libv8 的 Windows 上安装 therubyracer --with-system-v8

在 OS X 10.9+ 上安装 libv8 gem

修复 Mavericks 上的 ruby​​racer/libv8 (0.12.1) 安装

如何在 PHP5.5 上安装 V8js?

在 Rails 应用程序中,therubyracer 或 libv8 有啥用?