Gem install therubyracer -v '0.11.4'?

不想你离开。 提交于 2019-12-05 17:36:17

问题


I'm nearly crazy to install therubyracer. I know there're many people have the same problem with me, and I had also viewd these issues, however it's too complicated for me cause different situations have the different solutions. And in fact, there're have been not a good way to solve the problem. My problem is similar to this, and there have a discussion about it, however there're still have not a conclusion.

In spite of these, this is a good question asked by Chris S, but come not a good result.

① Here is some notes about my problem:

1.ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin15]

2.libv8 3.11.8.17 with native extensions

② OS X El Capitan, 10.11

③ Here is the error messages:

ERROR:  Error installing therubyracer:
ERROR: Failed to build gem native extension.

/Users/hufeipeng/.rbenv/versions/2.2.1/bin/ruby -r ./siteconf20151026-41811-14t2l9a.rb extconf.rb

checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
checking for v8.h... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling accessor.cc
clang: warning: argument unused during compilation: '-rdynamic'
In file included from accessor.cc:1:
In file included from ./rr.h:4:
/usr/local/include/v8.h:353:33: error: use of undeclared identifier 'nullptr'
V8_INLINE MaybeLocal() : val_(nullptr) {}
                            ^
/usr/local/include/v8.h:360:51: error: use of undeclared identifier 'nullptr'
V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
                                              ^
/usr/local/include/v8.h:364:29: error: use of undeclared identifier 'nullptr'
out->val_ = IsEmpty() ? nullptr : this->val_;
                        ^
/usr/local/include/v8.h:430:50: error: use of undeclared identifier 'nullptr'
bool IsFirstPass() const { return callback_ != nullptr; }
                                             ^
/usr/local/include/v8.h:790:42: error: use of undeclared identifier 'nullptr'
V8_INLINE Global() : PersistentBase<T>(nullptr) {}
                                     ^
/usr/local/include/v8.h:815:18: error: use of undeclared identifier 'nullptr'
other.val_ = nullptr;
             ^
/usr/local/include/v8.h:827:18: error: use of undeclared identifier 'nullptr'
rhs.val_ = nullptr;
             ^
/usr/local/include/v8.h:1092:52: error: use of undeclared identifier 'nullptr'
ScriptOrigin* origin = nullptr));
                         ^
/usr/local/include/v8config.h:347:48: note: expanded from macro 'V8_DEPRECATE_SOON'
#define V8_DEPRECATE_SOON(message, declarator) declarator
                                           ^
In file included from accessor.cc:1:
In file included from ./rr.h:4:
/usr/local/include/v8.h:1095:30: error: use of undeclared identifier 'nullptr'
ScriptOrigin* origin = nullptr);
                         ^
/usr/local/include/v8.h:2283:42: error: 'v8::NewStringType' is not a class, namespace, or scoped enumeration
kNormalString = static_cast<int>(v8::NewStringType::kNormal),
                                     ^
/usr/local/include/v8.h:2284:48: error: 'v8::NewStringType' is not a class, namespace, or scoped enumeration
kInternalizedString = static_cast<int>(v8::NewStringType::kInternalized)
                                           ^
/usr/local/include/v8.h:3205:36: error: use of undeclared identifier 'nullptr'
return NewInstance(context, 0, nullptr);
                               ^
/usr/local/include/v8.h:3434:38: error: 'v8::ArrayBufferCreationMode' is not a class, namespace, or scoped enumeration
ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
                                 ^
/usr/local/include/v8.h:3797:38: error: 'v8::ArrayBufferCreationMode' is not a class, namespace, or scoped enumeration
ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
                                 ^
/usr/local/include/v8.h:4457:36: error: 'v8::PropertyHandlerFlags' is not a class, namespace, or scoped enumeration
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
                             ^
/usr/local/include/v8.h:4485:36: error: 'v8::PropertyHandlerFlags' is not a class, namespace, or scoped enumeration
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
                             ^
/usr/local/include/v8.h:7151:27: error: use of undeclared identifier 'nullptr'
if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty();
                        ^
/usr/local/include/v8config.h:353:54: note: expanded from macro 'V8_UNLIKELY'
# define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0))
                                                 ^
In file included from accessor.cc:1:
In file included from ./rr.h:4:
/usr/local/include/v8.h:7596:46: error: 'v8::NewStringType' is not a class, namespace, or scoped enumeration
Set(v8::String::NewFromUtf8(isolate, name, NewStringType::kNormal)
                                         ^
In file included from accessor.cc:1:
./rr.h:358:39: error: no member named 'ScriptData' in namespace 'v8'
class ScriptData : public Pointer<v8::ScriptData> {
                              ~~~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [accessor.o] Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/*/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/therubyracer-0.11.4 for inspection.
Results logged to
/Users/*/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/therubyracer-0.11.4/gem_make.out

Help!



Well, firstly I'm so sorry to reedit the problem again, too busy no time to notice the comments your guys replied for me. And, here, I'm so appreciated that @Javid Jamae afford so great a way to me to solve the problem, although there're still some little matters to deal, but it's ok that we just need the errors to help us find the final answer. The follow is the console after I had try @Javid Jamae way,

First, I have not install gcc with brew before, so I installed it with brew and the version is the latest 5.2.0 (/usr/local/Cellar/gcc/5.2.0). Here is the details:

➜  /Users/xxx  >brew install gcc
==> Installing dependencies for gcc: gmp, mpfr, libmpc, isl
==> Installing gcc dependency: gmp
==> Downloading https://homebrew.bintray.com/bottles/gmp-6.0.0a.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gmp-6.0.0a.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/gmp/6.0.0a: 15 files, 3.2M
==> Installing gcc dependency: mpfr
==> Downloading https://homebrew.bintray.com/bottles/mpfr-3.1.3.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mpfr-3.1.3.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/mpfr/3.1.3: 24 files, 3.6M
==> Installing gcc dependency: libmpc
==> Downloading https://homebrew.bintray.com/bottles/libmpc-1.0.3.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libmpc-1.0.3.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/libmpc/1.0.3: 10 files, 380K
==> Installing gcc dependency: isl
==> Downloading https://homebrew.bintray.com/bottles/isl-0.14.1.el_capitan.bottle.3.tar.gz
######################################################################## 100.0%
==> Pouring isl-0.14.1.el_capitan.bottle.3.tar.gz
🍺  /usr/local/Cellar/isl/0.14.1: 68 files, 3.2M
==> Installing gcc
==> Downloading https://homebrew.bintray.com/bottles/gcc-5.2.0.el_capitan.bottle.2.tar.gz
##################### 29.8%
curl: (56) SSLRead() return error -9806
Error: Failed to download resource "gcc"
Download failed: https://homebrew.bintray.com/bottles/gcc-5.2.0.el_capitan.bottle.2.tar.gz
Warning: Bottle installation failed: building from source.
==> Downloading http://ftpmirror.gnu.org/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2
==> Downloading from http://mirrors.ustc.edu.cn/gnu/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2
######################################################################## 100.0%
==> Patching
patching file gcc/jit/Make-lang.in
patching file gcc/jit/jit-playback.c
Hunk #1 succeeded at 2459 with fuzz 2 (offset 43 lines).
==> ../configure --build=x86_64-apple-darwin15.0.0 --prefix=/usr/local/Cellar/gcc/5.2.0 --libdir=/usr/local/Cel
==> make bootstrap
==> make install
==> Caveats
GCC has been built with multilib support. Notably, OpenMP may not work:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60670
If you need OpenMP support you may want to brew reinstall gcc --without-multilib
==> Summary
🍺  /usr/local/Cellar/gcc/5.2.0: 1353 files, 248M, built in 52.4 minutes

It's seems the installation is ok! And then, I had uninstalled the therubyracer and libv8 with gem. However when it comes to install the therubyracer (I didn't point the version when install or in Gemfile, and the bundle remind me the version 0.12.2 is need), there're comes the error:

➜  /Users/xxx/Documents/workspace/xxx git:(master) ✗ >gem install therubyracer -v '0.12.2'
Fetching: libv8-3.16.14.13.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
ERROR: Failed to build gem native extension.
/Users/xxx/.rbenv/versions/2.2.1/bin/ruby -r ./siteconf20151230-50968-1yqguip.rb extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.10
Using compiler: /usr/bin/c++ (clang version 6.1.0)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file:
/Users/xxx/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o has no symbols
In file included from ../src/accessors.cc:28:
In file included from ../src/v8.h:60:
In file included from ../src/objects-inl.h:38:
In file included from ../src/elements.h:33:
In file included from ../src/heap.h:35:
In file included from ../src/incremental-marking.h:33:
In file included from ../src/mark-compact.h:32:
../src/spaces.h:896:26: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true [-Werror,-Wtautological-undefined-compare]
bool exists() { return this != NULL && code_range_ != NULL; }
                     ^~~~    ~~~~
../src/spaces.h:898:9: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false [-Werror,-Wtautological-undefined-compare]
if (this == NULL || code_range_ == NULL) return false;
    ^~~~    ~~~~
2 errors generated.
make[1]: ***
[/Users/xxx/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o]
Error 1
make: *** [x64.release] Error 2
/Users/xxx/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.13/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '
/Users/xxx/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
from
/Users/xxx/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.13/ext/libv8/location.rb:35:in `each'
from
/Uses/xxx/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.13/ext/libv8/location.rb:35:in `verify_installation!'
from
/Users/xxx/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.13/ext/libv8/location.rb:26:in `install!'
from extconf.rb:7:in `<main>'
GYP_GENERATORS=make \
build/gyp/gyp --generator-output="out" build/all.gyp \
              -Ibuild/standalone.gypi --depth=. \
              -Dv8_target_arch=x64 \
              -S.x64  -Dv8_enable_backtrace=1 -
Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -
Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror=''
CXX(target)
/Users/xxx/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
CXX(target)
/Users/xxx/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
CXX(target)
/Users/xxx/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
.................. (the follow error messages are similar to above)

Well, I'm wonder it's still the problem of the libv8! At first, I think it's maybe the problem of the version of therubyracer, so I had make a try to install the version 0.12.0, unfortunately, there're the same errors. There're something strange, I mean the libv8 is installed with the therubyracer in my case (see that from the error messages), but you're different with me. As your suggestion marked you install the libv8 after you had installed the therubyracer, why they're different? Maybe it's relate to my ruby environment settings, here I posted my Gemfile configuration:

gem 'rails', '4.1.6'
gem 'mysql2', '0.3.18'
gem 'sass-rails', '~> 4.0.3'
gem 'bootstrap-sass', '~> 3.3.4'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'

gem 'therubyracer', platforms: :ruby

gem 'jquery-rails','3.1.2'
gem 'jquery-ui-rails', '4.0.5'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'log4r', '1.1.9'
gem 'devise','3.4.1'
gem 'carrierwave', '0.10.0'
gem 'mini_magick', '3.6.0'
gem 'thin','1.6.2'
gem 'kaminari', '0.16.1'
gem 'factory_girl_rails'
gem 'httparty'
gem "select2-rails",'3.5.9.3'

group :test, :development do
    gem 'net-ssh', '2.7.0'
    gem 'capistrano', '2.12.0'
    gem 'capistrano-rbenv', '1.0.1'
    gem 'spring'
    gem 'magic_encoding', '0.0.2'
    gem 'rspec-rails', '3.2.0'
end

回答1:


I had the sam problem in OSX El Capitan. The steps I used to get over this were

First check if V8 is installed or not. I used brew to install it.

brew install homebrew/versions/v8-315

Try uninstalling libv8, therubyracer gems if some instance exists.

gem uninstall -a libv8
gem uninstall -a therubyracer

Then install the libv8 gem.

gem install libv8 -v '<<VERSION>>' -- --with-system-v8

Then install the therubyracer gem.

gem install therubyracer -v '<<VERSION>>' -- --with-v8-dir=$(brew --prefix v8-315)



回答2:


This worked for me:

$ brew upgrade gcc

$ gem uninstall therubyracer

$ gem uninstall libv8

$ gem install therubyracer -v '0.12.0'
Fetching: therubyracer-0.12.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed therubyracer-0.12.0
1 gem installed

$ gem install libv8 -v '3.16.14.3' -- --with-system-v8
Fetching: libv8-3.16.14.3.gem (100%)
Building native extensions with: '--with-system-v8'
This could take a while...
Successfully installed libv8-3.16.14.3
1 gem installed

References:

  • https://github.com/cowboyd/therubyracer/issues/398
  • https://github.com/cowboyd/therubyracer/issues/288#issuecomment-63923606



回答3:


I had the same problem, updating therubyracer to the latest version solved the issue.

Try:

bundle update therubyracer

If you also have issues with libv8 then try:

bundle update libv8


来源:https://stackoverflow.com/questions/33343159/gem-install-therubyracer-v-0-11-4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!