问题
When I try to install therubyracer, I get the following error:
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.
I have no idea of what's happening.
回答1:
Actually, it was a little tricky.
I use my custom dotfiles, so, I have ~/.dotfiles/bin
in my PATH.
I also been noticed that the issue is related to python v3 vs v2.
So, the fix was pretty easy, without break my system:
ln -s /usr/bin/python2 ~/.dotfiles/bin
reload
gem install libv8 --verbose
bundle
Leaving my Gemfile
like this:
[...]
gem 'therubyracer', :require => 'v8', :platforms => :ruby
[...]
And BOOM, it worked.
Thanks for your help guys. Sorry for the delay to reply.
Cheers
EDIT
Issue was fixed in the newer therubyracer release (0.11.1).
回答2:
I have the same issue in my ArchLinux. This is a known issue. the workaround that worked for my on archlinux was locking to 0.10.2
, by adding following line in Gemfile
gem 'therubyracer', '0.10.2', :platforms => :ruby
I have tested this & it works atleast on 64bit. Hopefully it would work for you as well.
回答3:
I would highly recommend using external Node.js (I am sure there's an official package for that) and then use sstephenson / execjs.
If you are using Rails, it already depends on ExecJS so you might just remove the dependency on therubyracer
, bundle, install Node.js and you are good to go.
回答4:
You need to install libv8 3.11.x to get latest versions of therubyracer. So try updating libv8 and then do bundle.
来源:https://stackoverflow.com/questions/13999070/i-cant-install-therubyracer-in-arch-linux-x64