当我尝试安装therubyracer时,出现以下错误:
Installing therubyracer (0.11.0) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/home/carlos/.rbenv/versions/1.9.3-p327/bin/ruby extconf.rb
checking for main() in -lpthread... yes
checking for v8.h... yes
creating Makefile
make
compiling script.cc
compiling v8.cc
compiling backref.cc
compiling value.cc
compiling accessor.cc
compiling trycatch.cc
compiling primitive.cc
compiling external.cc
compiling date.cc
compiling exception.cc
compiling init.cc
compiling template.cc
compiling message.cc
compiling stack.cc
compiling gc.cc
compiling string.cc
compiling handles.cc
compiling function.cc
compiling heap.cc
compiling invocation.cc
compiling locker.cc
compiling object.cc
compiling array.cc
compiling constants.cc
compiling rr.cc
compiling signature.cc
compiling constraints.cc
compiling context.cc
context.cc: In static member function ‘static VALUE rr::Context::SetData(VALUE, VALUE)’:
context.cc:81:3: error: no matching function for call to ‘v8::Context::SetData(rr::String)’
context.cc:81:3: note: candidate is:
In file included from rr.h:4:0,
from context.cc:1:
/usr/include/v8.h:3721:8: note: void v8::Context::SetData(v8::Handle<v8::Value>)
/usr/include/v8.h:3721:8: note: no known conversion for argument 1 from ‘rr::String’ to ‘v8::Handle<v8::Value>’
make: *** [context.o] Error 1
Gem files will remain installed in /home/carlos/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0 for inspection.
Results logged to /home/carlos/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0/ext/v8/gem_make.out
An error occurred while installing therubyracer (0.11.0), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.11.0'` succeeds before bundling.
我不知道发生了什么。
答案 0 :(得分:4)
实际上,这有点棘手。
我使用自定义dotfiles,因此,我的路径中有~/.dotfiles/bin
。
我也是been noticed that the issue is related to python v3 vs v2。
所以,修复非常简单,不会破坏我的系统:
ln -s /usr/bin/python2 ~/.dotfiles/bin
reload
gem install libv8 --verbose
bundle
离开我的Gemfile
:
[...]
gem 'therubyracer', :require => 'v8', :platforms => :ruby
[...]
和BOOM一起工作。
感谢您的帮助。很抱歉延迟回复。
干杯
问题在较新的therubyracer版本(0.11.1)中得到修复。
答案 1 :(得分:3)
我在ArchLinux中遇到了同样的问题。这是known issue。通过在0.10.2
Gemfile
的解决方法适用于我的archlinux
gem 'therubyracer', '0.10.2', :platforms => :ruby
我测试了这个&amp;它至少可以在64位上运行。希望它对你也有用。
答案 2 :(得分:2)
我强烈建议使用外部Node.js(我相信有一个正式的包),然后使用sstephenson / execjs。
如果你使用的是Rails,它已经依赖于ExecJS,所以你可能只是删除对therubyracer
的依赖,捆绑,安装Node.js,你就可以了。
答案 3 :(得分:1)
您需要安装libv8 3.11.x才能获得最新版本的therubyracer。 所以尝试更新libv8然后再捆绑。