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 */
你可以使用brew中的Libv8,而不是使用gem中的Libv8。 你可以通过下面的命令来完成:
$ gem uninstall libv8 $ brew install v8 $ gem install therubyracer
对于一个较老的项目,我不得不在特立独行上使用0.10.1版本的rubyracer(bootstrap依赖于它)
所以我不得不使用旧版本的gcc
-
编辑你的.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
-
确保你已经卸载了libv8的所有旧版本
gem uninstall libv8
-
安装您的therubyracer版本
gem install therubyracer -v=0.10.1
在小牛,你只需要更新到therubyracer 0.12.0
为我工作的解决scheme是把这些步骤放在一起10.7.4
export CC=gcc-4.2 sudo ln /usr/bin/gcc /usr/bin/gcc-4.2 gem uninstall libv8 gem install therubyracer
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 !
对于Linux:
下面的代码当然是正确的
$ gem uninstall libv8
$ gem install therubyracer
但是有时候没有帮助,因为你没有编程。 首先你需要安装make
。 要做到这一点,运行:
sudo apt-get install build-essential
只有在那之后:
gem install therubyracer
到目前为止,我的确有同样的问题。
这个链接救了我。
总结一下,你需要做到这一点:
$ gem uninstall libv8 $ gem install therubyracer
在我解决这个问题之前,我已经在我的Mac中安装了v8。 我不知道这是否有帮助,因为它似乎与JS解释器有关,我认为这可能会有所帮助。
在Mountain Lion 10.8上,它并没有预装C编译器。 您需要从Apple下载并安装“命令行工具”包,然后运行which gcc
来确认它已经安装。 一切都应该从那里运行良好。
在OS X 10.7上,我发现“命令行工具”包是不够的,我不得不安装完整的XCode包,然后gem install工作。
从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)gem安装没有问题。
假设你使用rbenv:
rbenv install 1.9.3-rc1 rbenv rehash rbenv shell 1.9.3-rc1 bundle install