2015-10-26 165 views
9

我幾乎瘋狂地安裝therubyracer。我知道有很多人與我有同樣的問題,我也看到了這些問題,但對我來說這太複雜了,因爲不同的情況有不同的解決方案。事實上,解決這個問題並不是一個好方法。我的問題類似於this,並且有關於它的​​,但是仍然沒有結論。Gem install therubyracer -v'0.11.4'?

儘管如此,this是一個很好的問題,由問的克里斯S,但不是一個好的結果。

①這裏是我的問題的一些注意事項:

1.ruby 2.2.1p85(2015年2月26日修訂49769)x86_64的-darwin15]

2.libv8 3.11.8.17與原生擴展

②OS X EI匹,10.11

③以下是錯誤消息:

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 

幫助!



嗯,首先我很抱歉再次重新編輯的問題,忙得沒有時間去注意你的人回答說,我的意見。而且,在這裏,我很欣賞@Javid Jamae爲我解決問題提供了非常好的方式,儘管還有一些小問題需要處理,但沒關係,我們只需要這些錯誤來幫助我們找到最終答案。後續是控制檯後,我曾嘗試@Javid詹美回教堂路,

首先,我沒有安裝GCC 沖泡以前,所以我沖泡安裝了版本爲最新的5.2.0 /usr/local/Cellar/gcc/5.2.0)。這裏是細節:

➜ /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 

這似乎是安裝好!然後,我卸載了帶有寶石的溫度記錄儀libv8。然而,當涉及到安裝therubyracer(我沒點時或安裝的Gemfile的版本,和提醒我的版本0.12.2是需要),還有就是自帶的錯誤:

➜ /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) 

好吧,我不知道它仍然是libv8的問題!起初,我認爲這可能是版本therubyracer的問題,所以我試圖安裝版本0.12.0,不幸的是,這裏有相同的錯誤。有一些奇怪的東西,我的意思是libv8therubyracer安裝在我的情況下(請參閱從錯誤消息),但你是不同於我。根據你的建議,你在安裝therubyracer後安裝了libv8,爲什麼它們不同?也許這涉及到我的紅寶石環境設置,在這裏我貼我的的Gemfile配置:

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 

夥計們,又需要您的幫助!

+0

你知道了嗎?遇到同樣的問題,它殺了我。 – trevorhinesley

+0

@ frank-jorsn - 我讀了你在編輯中留下的評論以迴應我的迴應(被拒絕)。你說gcc安裝成功了,但是如果你再看看你的輸出,你會發現它不是:'錯誤:無法下載資源「gcc」'。我不太瞭解它,但要確保gcc安裝正確,我認爲我的解決方案可以爲你工作。祝你好運! –

+0

@Javid Jamae,好吧,我很抱歉回覆你的評論吧。我在一家公司的項目中非常忙,以至於很長一段時間沒有注意到我的stackoverflow通知。我已閱讀您的評論,您在評論中提醒的gcc安裝問題並不完全正確。我真的以正確的方式安裝了gcc,在我編輯的響應中,從未說過安裝的gcc失敗,它只是下載資源失敗的一個,但嘗試另一個資源成功。這些可以在最後的響應控制檯內容中檢查,恐怕你失去了細節。我將在下面爲您再次複製控制檯! –

回答

8

我在OSX埃爾卡皮坦山姆問題。我用來解決這個問題的步驟是:

首先檢查是否安裝了V8。我用brew來安裝它。

brew install homebrew/versions/v8-315 

嘗試卸載libv8,therubyracer寶石,如果有一些實例存在。

gem uninstall -a libv8 
gem uninstall -a therubyracer 

然後安裝libv8 gem。

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

然後安裝therubyracer寶石。

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

如此讚賞和如此令人興奮的關於與*** libv8 ***,*** V8 ***和*** therubyracer ***的依賴關係的類型問題得到解決! @Pranshu Verma你真的幫了我很多,讓我知道三者之間的關係。我會根據我的理解對此做出結論,再次感謝。 –

+0

它爲我工作,我省略了'-v <>'的參數。 –

0

我有同樣的問題,更新therubyracer到最新版本解決了這個問題。

嘗試:

bundle update therubyracer 

如果你也有libv8問題,然後再嘗試:

bundle update libv8 
+0

嗨,@ user1894919!也許你的解決方案是解決** therubyracer **和「libv8」版本問題的好方法,但它不能解決我的問題。你應該知道我有問題**安裝** therubyracer **,這意味着我從來沒有安裝** therubyracer **到我的電腦,所以**更新**的方式是不是一個好主意我。這裏是錯誤消息:** $ bundle update therubyracer ** - > **這個Bundle尚未安裝。運行'bundle install'來更新和安裝捆綁的寶石。**無論如何,謝謝! –

+0

在這種情況下,您好@frankjorsn嘗試編輯Gemfile以使用最新版本的therubyracer以及libv8(如果需要),然後運行軟件包安裝,這可能適用於您。對不起,延遲,我只看到你的回覆。 – user1894919

10

這爲我工作:

$ 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 

參考文獻:

+1

其次..經過多次鬥爭,這對我工作! –

+1

第三。在這個線程和其他許多解決方案中,我嘗試了十多種解決方案,然後纔開始工作。我實際上不得不這樣做: '$ brew install gcc' ...花了35分鐘完成,但隨後therubyracer終於提交正在安裝。 –