ruby-on-rails - gem install therubyracer -v 0.11.4 在 OS X 10.10 上失败

标签 ruby-on-rails ruby macos osx-yosemite therubyracer

按照此处的步骤操作 "gem install therubyracer -v '0.10.2'" on osx mavericks not installing ,我能够让 therubyracer -v 0.10.2 和 0.12.0 安装正常,但不能安装 0.11.4。

gem install therubyracer -v 0.11.4

返回:

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

    /Users/thooper/.rbenv/versions/2.1.2/bin/ruby -r ./siteconf20150102-7132-9ct9a4.rb extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.9
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Using compiler: g++
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
                 ^
1 error generated.
make[1]: *** [/Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o] Error 1
make: *** [x64.release] Error 2
/Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
    from /Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17/ext/libv8/location.rb:35:in `each'
    from /Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17/ext/libv8/location.rb:35:in `verify_installation!'
    from /Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17/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=x64 \
                  -S.x64  -Dv8_can_use_vfp_instructions=true
  CXX(target) /Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
  CXX(target) /Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
  CXX(target) /Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
  CXX(target) /Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
  CXX(target) /Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o

extconf failed, exit code 1

Gem files will remain installed in /Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.11.8.17 for inspection.
Results logged to /Users/thooper/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-14/2.1.0-static/libv8-3.11.8.17/gem_make.out

最佳答案

这正是我遇到的问题,我使用自制软件版本解决了它。

问题

我在安装 gem libv8 时遇到了问题。为了解决这个问题,我通过 brew 在我的系统上安装了 v8,然后使用选项 --with-system-v8

$ brew install v8
$ gem install libv8 -v '3.11.8.13' -- --with-system-v8
$ gem install therubyracer -v '0.11.4'

gem libv8 安装没有问题,但是最后一行导致了原始问题的错误。然后我试了一下,

$ gem install therubyracer -v '0.11.4' -- --with-system-v8 --with-v8-dir=/usr/local/Cellar/v8/3.30.33.16

将其指向 brew 提供的 v8。在那种情况下,错误发生了变化,现在告诉我我没有提供与 3.11.8.13 兼容的 v8 版本。

对于那些在谷歌上搜索错误信息的人:

Building native extensions with: '--with-v8-dir=/usr/local/Cellar/v8/3.30.33.16/'
This could take a while...
ERROR:  Error installing therubyracer:
    ERROR: Failed to build gem native extension.

    /Users/zeigfreid/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb --with-v8-dir=/usr/local/Cellar/v8/3.30.33.16/
checking for main() in -lpthread... yes
checking for main() in -lobjc... 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
    --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=/Users/zeigfreid/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
    --with-pthreadlib
    --without-pthreadlib
    --with-objclib
    --without-objclib
    --enable-debug
    --disable-debug
    --with-v8-dir
    --with-v8-include
    --without-v8-include=${v8-dir}/include
    --with-v8-lib
    --without-v8-lib=${v8-dir}/lib
/Users/zeigfreid/.rvm/gems/ruby-1.9.3-p194@va_rails_3.2.11/gems/libv8-3.11.8.13/ext/libv8/location.rb:50:in `configure': You have chosen to use the version of V8 found on your system (Libv8::Location::System::NotFoundError)
and *not* the one that is bundle with the libv8 rubygem. However,
it could not be located. please make sure you have a version of
v8 that is compatible with 3.11.8.13 installed. You may
need to special --with-v8-dir options if it is in a non-standard
location

thanks,
The Mgmt

    from /Users/zeigfreid/.rvm/gems/ruby-1.9.3-p194@va_rails_3.2.11/gems/libv8-3.11.8.13/lib/libv8.rb:7:in `configure_makefile'
    from extconf.rb:32:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/zeigfreid/.rvm/gems/ruby-1.9.3-p194@va_rails_3.2.11/gems/therubyracer-0.11.4 for inspection.
Results logged to /Users/zeigfreid/.rvm/gems/ruby-1.9.3-p194@va_rails_3.2.11/extensions/x86_64-darwin-13/1.9.1/therubyracer-0.11.4/gem_make.out

解决方案

我决定尝试安装早期版本的 v8。再次使用 brew,

$ brew search v8
homebrew/versions/v8-315   v8
$ brew install v8-315
$ brew info v8-315
$ gem install therubyracer -v '0.11.4' -- --with-system-v8 --with-v8-dir=/usr/local/Cellar/v8-315/3.15.11

这成功了。我最终安装的 v8 版本是 ~3.15,但这与 3.11.8 兼容

这里真正的解决方案是将所有内容更新到最新版本,我不提倡使用旧的和过时的 gem。保持您的系统清洁和最新,即使它受到伤害!

关于ruby-on-rails - gem install therubyracer -v 0.11.4 在 OS X 10.10 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27747066/

相关文章:

php - 制作一个 ruby​​ on Rails API 以与已经完成的 php 系统共享 mysql 数据库

ruby-on-rails - worker 终止后,Heroku cedar stack 上的 Resque worker 计数仍然存在

ruby - 获取 Sinatra 请求路由/路径

ruby-on-rails - 自引用问题 has_many :through associations in Rails

mysqld 在 Mac OS 上启动和停止

macos - 在 shell 脚本中执行 Vim 命令

ruby-on-rails - NameError:未初始化的常量 Rails::TestTask

mysql - jruby公共(public)数据库适配器

OSX 10.9 上的 Java 速度变慢

Ruby 更新 1.8.7 至 1.9.3