2017-02-18 83 views
3

我剛剛首次從GitHub克隆了一個存儲庫。錯誤:安裝oj時出錯:

我去看看我的本地機器上,所以我的Mac上的本地倉庫內我跑以下命令

斌/導軌服務器

我得到了以下錯誤:

無法在任何來源中找到activesupport-5.0.0.1 運行bundle install以安裝缺失的寶石。

所以我然後跑捆綁安裝命令的建議,但隨後它給了我下面的錯誤

在安裝OJ(14年2月12日)發生了錯誤,並且捆紮機無法繼續。 確保gem install oj -v '2.12.14'在捆綁之前成功。

所以的建議,我跑:創業板安裝OJ -v「14年2月12日」

然後我得到的警告很長的信息及錯誤(見下文)。有什麼想法嗎?

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

    current directory: /usr/local/lib/ruby/gems/2.4.0/gems/oj-2.12.14/ext/oj 

/usr/local/opt/ruby/bin/ruby -r ./siteconf20170218-3717-1p2bvl9.rb extconf.rb 

>>>>> Creating Makefile for ruby version 2.4.0 on x86_64-darwin16 <<<<< 

creating Makefile 



current directory: /usr/local/lib/ruby/gems/2.4.0/gems/oj-2.12.14/ext/oj 

make "DESTDIR=" clean 



current directory: /usr/local/lib/ruby/gems/2.4.0/gems/oj-2.12.14/ext/oj 

make "DESTDIR=" 

compiling cache8.c 

compiling circarray.c 

compiling compat.c 

compiling dump.c 

dump.c:503:8: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] 

     cnt = RSTRING_LEN(rstr); 

      ~ ^~~~~~~~~~~~~~~~~ 

/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/ruby.h:976:6: note: expanded from macro 'RSTRING_LEN' 

    RSTRING_EMBED_LEN(str) : \ 

    ^~~~~~~~~~~~~~~~~~~~~~ 

/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/ruby.h:972:6: note: expanded from macro 'RSTRING_EMBED_LEN' 

    (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \ 

    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

dump.c:503:8: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] 

     cnt = RSTRING_LEN(rstr); 

      ~ ^~~~~~~~~~~~~~~~~ 

/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/ruby.h:977:28: note: expanded from macro 'RSTRING_LEN' 

    RSTRING(str)->as.heap.len) 

    ~~~~~~~~~~~~~~~~~~~~~~^~~ 

dump.c:1776:39: warning: 'rb_struct_ptr' is deprecated [-Wdeprecated-declarations] 

     for (i = (int)RSTRUCT_LEN(obj), vp = RSTRUCT_PTR(obj); 0 < i; i--, vp++) { 

              ^

/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/ruby.h:1190:33: note: expanded from macro 'RSTRUCT_PTR' 

#define RSTRUCT_PTR(st)   rb_struct_ptr(st) 

           ^

/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/intern.h:889:25: note: 'rb_struct_ptr' has been explicitly marked deprecated here 

DEPRECATED(const VALUE *rb_struct_ptr(VALUE s)); 

         ^

dump.c:1776:37: warning: assigning to 'VALUE *' (aka 'unsigned long *') from 'const VALUE *' (aka 'const unsigned long *') discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] 

     for (i = (int)RSTRUCT_LEN(obj), vp = RSTRUCT_PTR(obj); 0 < i; i--, vp++) { 

             ^~~~~~~~~~~~~~~~~ 

4 warnings generated. 

compiling err.c 

compiling fast.c 

fast.c:816:17: warning: 'rb_data_object_alloc' is deprecated: by rb_data_object_wrap [-Wdeprecated-declarations] 

    doc->self = rb_data_object_alloc(clas, doc, 0, free_doc_cb); 

       ^

/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/ruby.h:1379:1: note: 'rb_data_object_alloc' has been explicitly marked deprecated here 

rb_data_object_alloc(VALUE klass, void *data, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree) 

^ 

fast.c:1280:24: error: use of undeclared identifier 'rb_cFixnum' 

     case T_FIXNUM: type = rb_cFixnum;  break; 

          ^

1 warning and 1 error generated. 

make: *** [fast.o] Error 1 



make failed, exit code 2 



Gem files will remain installed in /usr/local/lib/ruby/gems/2.4.0/gems/oj-2.12.14 for inspection. 

Results logged to /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/oj-2.12.14/gem_make.out 

回答

6

Fixnum不再是紅寶石2.4的東西。降級你的紅寶石或更新oj到2.16.1,它支持ruby 2.4。

+0

我試着升級oj到2.16.1,它工作。然而,當我嘗試捆綁安裝時,它又給了我同樣的錯誤,說確保'gem install oj -v'2.12.14''捆綁成功。所以,下一個想法是按照你的建議降級Ruby,但是我怎樣才能做到這一點呢?我認爲我遇到的問題是我已成功設置ruby,但是我克隆了一個存儲庫,可能它的代碼依賴於舊版本的ruby或不同版本的oj。我假設我應該使用RVM以某種方式爲此存儲庫設置Ruby版本? –

+0

@KramerKeller你需要在運行'bundle install'前運行'bundle update oj'來更新oj到Gemfile.lock中的最新版本。據說,使用rvm或其他管理器來管理你的ruby安裝總是一個好主意。大多數管理者通過在目錄中查找_.ruby-version_文件來確定要使用哪個版本的ruby。如果您克隆的存儲庫已經有一個,我不會感到驚訝。 – eiko

+0

我完全刪除了RVM。我也刪除了我的存儲庫。我創建了一個新文件並克隆了存儲庫並使rbenv工作。我可以看到我在本地運行2.3.1,但我仍然遇到同樣的錯誤。它說「安裝oj(2.12.14)時發生錯誤,並且Bundler無法繼續。」捆綁更新oj給出了相同的錯誤。寶石安裝似乎引用紅寶石2.4 ...所以如何獲得2.3.1的寶石與我的克隆回購工作?我也檢查了我的gem文件,它說'oj','〜> 2.12.14'和Gemfile.lock說oj(2.12.14)。我正在嘗試學習紅寶石......但無法在我的機器上運行。 –