therubyracer安装错误(therubyracer install error)

2019-06-26 11:00发布

正如你可以看到下面,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 */

Answer 1:

您可以从酿造,而不是从宝石的一个使用Libv8。 你可以通过下面的命令:

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


Answer 2:

对于较旧的项目,我必须用在小牛的0.10.1版本rubyracer的(引导依赖于它)

因此,我不得不使用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 


Answer 3:

对于Linux:

下面的代码是当然正确的

$ gem uninstall libv8

$ gem install therubyracer

但有时但这并没有帮助,因为你没有计划make 。 首先 ,您需要安装make 。 要做到这一点,运行:

sudo apt-get install build-essential

只有经过:

gem install therubyracer



Answer 4:

在小牛,你只需要更新到therubyracer 0.12.0



Answer 5:

为我工作的解决方案是把这些步骤一起10.7.4

export CC=gcc-4.2

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

gem uninstall libv8
gem install therubyracer


Answer 6:

苹果10.10.5,红宝石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 !


Answer 7:

我有完全相同的问题,只是到现在。

此链接救了我。

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

$ gem uninstall libv8
$ gem install therubyracer

之前,我修复了这个问题,我已经安装在我的Mac V8。 我不知道这是否帮助,因为它似乎有东西做JS解释,我想这可能帮助。



Answer 8:

在山狮10.8,它不会与C编译器预装。 你需要下载和安装苹果自己的“命令行工具”包,然后运行which gcc ,以确认它安装。 一切都应该从那里上运行良好。



Answer 9:

在OS X 10.7我居然发现了“命令行工具”包还不够,我必须安装全面爆发的XCode包,那么创业板安装工作。



Answer 10:

我有同样的问题,当我从OSX山狮OSX小牛升级。

从红宝石-1.8.7-P354升级到红宝石1.8.7-375奏效了我。 如果你是红宝石1.93-P125,你可能想尝试升级到1.9.3-RC1(也就是上面P484已经)

libv8(3.16.14.3-x86_64的-达尔文-13)和没有问题地安装在therubyracer(0.12.0)宝石。

假设你使用rbenv:

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


Answer 11:

据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



Answer 12:

@ 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)


文章来源: therubyracer install error