therubyracer安装错误

时间:2012-07-22 08:04:05

标签: gem therubyracer

正如你在下面看到的,libv8安装得很好,但是therubyracer却没有。我正在使用Mac 10.7.4。

~/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1> gem install libv8
Building native extensions.  This could take a while...
Successfully installed libv8-3.11.8.3
1 gem installed
Installing ri documentation for libv8-3.11.8.3...
Installing RDoc documentation for libv8-3.11.8.3...

~/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1> gem install therubyracer
Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
    ERROR: Failed to build gem native extension.

        /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for main() in -lobjc... *** 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/rdp/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
    --with-objclib
    --without-objclib
/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:840:in `have_library'
    from extconf.rb:10:in `<main>'


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

以下是mkmf.log,位于~/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/gems/1.9/gems/therubyracer-0.10.1/ext/v8>

文件编辑选项缓冲区工具帮助

"/usr/bin/gcc-4.2 -o conftest -I/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin11.3.0 -I/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/rub\
y/backward -I/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1 -I. -I/Users/rdp/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE    -O3 -ggdb -Wextra -Wno-unused-\
parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-functio\
n-declaration  -fno-common -pipe conftest.c  -L. -L/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib -L/Users/rdp/.rvm/usr/lib -L.      -lruby.1.9.1  -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */

13 个答案:

答案 0 :(得分:84)

您可以使用brew中的Libv8而不是gem中的Libv8。您可以通过以下命令执行此操作:

$ gem uninstall libv8
$ brew install v8
$ gem install therubyracer

答案 1 :(得分:10)

对于一个较旧的项目,我不得不在小牛上使用0.10.1版本的rubyracer(bootstrap取决于它)

所以我不得不使用旧版本的gcc

  1. 编辑.zshrc或.bashrc

    export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
    export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
    export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2
    
  2. 请确保已卸载所有旧版本的libv8

    gem uninstall libv8
    
  3. 安装你的版本的therubyracer

    gem install therubyracer -v=0.10.1
    

答案 2 :(得分:5)

对于Linux:

以下代码当然是正确的

$ gem uninstall libv8

$ gem install therubyracer

但有时候它没有帮助,因为你没有编程make AT FIRST 您需要安装make。为此,请运行:

sudo apt-get install build-essential

只有在那之后:

gem install therubyracer

答案 3 :(得分:3)

On Mavericks,你只需要更新到therubyracer 0.12.0

答案 4 :(得分:2)

为我工作这些步骤:

  • brew uninstall v8
  • brew install v8-315
  • gem uninstall -a libv8
  • gem uninstall -a therubyracer
  • gem install libv8 -v '3.16.14.19' -- --with-system-v8
  • gem install therubyracer -v '0.12.3' -- --with-v8-dir=$(brew --prefix v8-315)

答案 5 :(得分:1)

对我有用的解决方案是将这些步骤放在10.7.4上。

export CC=gcc-4.2

sudo ln /usr/bin/gcc /usr/bin/gcc-4.2

gem uninstall libv8
gem install therubyracer

答案 6 :(得分:1)

Mac 10.10.5,Ruby 2.1.0这对我有用:

gem uninstall libv8
gem uninstall therubyracer

brew upgrade gcc
brew install v8

bundle config --local build.libv8 --with-cxx=/usr/local/bin/gcc-6
gem install libv8 -v '3.16.14.17' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315

bundle install # worked !

答案 7 :(得分:0)

到目前为止,我遇到了完全相同的问题。

link救了我。

总结一下,你需要这样做:

$ gem uninstall libv8
$ gem install therubyracer

在我解决这个问题之前,我已经在我的mac中安装了v8。我不知道这是否有帮助,因为它似乎与js解释器有关,我认为它可能会有所帮助。

答案 8 :(得分:0)

在Mountain Lion 10.8上,它没有预装C编译器。您需要从Apple自己下载并安装“命令行工具”软件包,然后运行which gcc以确认已安装。从那里开始,一切都应该运行良好。

答案 9 :(得分:0)

在OS X 10.7上我实际上发现“命令行工具”包不够用,我必须安装完整的XCode包,然后gem install工作。

答案 10 :(得分:0)

当我从OSX Mountain Lion升级到OSX Mavericks时,我遇到了同样的问题。

从ruby-1.8.7-p354升级到ruby-1.8.7-375对我来说是个窍门。如果您使用的是ruby-1.93-p125,您可能需要尝试升级到1.9.3-rc1(已经高于p484)

libv8(3.16.14.3-x86_64-darwin-13)和安装的therubyracer(0.12.0)宝石没有问题。

假设您使用rbenv:

rbenv install 1.9.3-rc1
rbenv rehash
rbenv shell 1.9.3-rc1
bundle install

答案 11 :(得分:0)

根据https://github.com/cowboyd/therubyracer/issues/420#issuecomment-253592865

gem uninstall therubyracer
gem uninstall libv8
brew uninstall v8
brew install v8
gem install libv8
gem install therubyracer

它帮助了我。参数:ruby 2.3.3rails 4.2.9

答案 12 :(得分:0)

@Haegin在https://github.com/cowboyd/libv8/issues/205中的答案

brew uninstall v8
brew install v8-315
gem uninstall -a libv8
gem uninstall -a therubyracer
gem install libv8 -v '3.16.14.17' -- --with-system-v8
gem install therubyracer -v '0.12.2' -- --with-v8-dir=$(brew --prefix v8-315)