mysql - 安裝gem報(bào)錯(cuò)
問(wèn)題描述
1.相應(yīng)的環(huán)境: ubuntu12.04 ruby 2.4 2.通過(guò)
bundle install --deployment --without development test postgres aws
安裝gem的時(shí)候報(bào)錯(cuò):
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:/home/git/gitlab/vendor/bundle/ruby/2.4.0/gems/json-1.8.1/ext/json/ext/generator/usr/local/bin/ruby -r ./siteconf20170122-2448-oz1rn0.rb extconf.rbcreating Makefile
current directory:/home/git/gitlab/vendor/bundle/ruby/2.4.0/gems/json-1.8.1/ext/json/ext/generatormake 'DESTDIR=' clean
current directory:/home/git/gitlab/vendor/bundle/ruby/2.4.0/gems/json-1.8.1/ext/json/ext/generatormake 'DESTDIR=' compiling generator.c In file included fromgenerator.c:1:0: ../fbuffer/fbuffer.h: In function ’fbuffer_to_s’:../fbuffer/fbuffer.h:175:47: error: macro 'rb_str_new' requires 2arguments, but only 1 given ../fbuffer/fbuffer.h:175:20: warning:initialization makes integer from pointer without a cast [enabled bydefault] generator.c: In function ’generate_json’: generator.c:840:25:error: ’rb_cFixnum’ undeclared (first use in this function)generator.c:840:25: note: each undeclared identifier is reported onlyonce for each function it appears in generator.c:842:25: error:’rb_cBignum’ undeclared (first use in this function) generator.c: Attop level: cc1: warning: unrecognized command line option'-Wno-self-assign' [enabled by default] cc1: warning: unrecognizedcommand line option '-Wno-constant-logical-operand' [enabled bydefault] cc1: warning: unrecognized command line option'-Wno-parentheses-equality' [enabled by default] cc1: warning:unrecognized command line option '-Wno-tautological-compare' [enabledby default] make: * [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in/home/git/gitlab/vendor/bundle/ruby/2.4.0/gems/json-1.8.1 for
Results logged to/home/git/gitlab/vendor/bundle/ruby/2.4.0/extensions/x86-linux/2.4.0-static/json-1.8.1/gem_make.out
An error occurred while installing json (1.8.1), and Bundler cannot
Make sure that gem install json -v ’1.8.1’ succeeds before bundling.
但是看到Make sure that gem install json -v ’1.8.1’ succeeds before bundling.
于是我就手動(dòng)安裝了gem install json -v ’1.8.1’ ,依然報(bào)錯(cuò):
Building native extensions. This could take a while...ERROR: Error installing json: ERROR: Failed to build gem native extension. current directory: /usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.1/ext/json/ext/generator/usr/local/bin/ruby -r ./siteconf20170122-3475-aueo31.rb extconf.rbcreating Makefilecurrent directory: /usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.1/ext/json/ext/generatormake 'DESTDIR=' cleancurrent directory: /usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.1/ext/json/ext/generatormake 'DESTDIR='compiling generator.cIn file included from generator.c:1:0:../fbuffer/fbuffer.h: In function ’fbuffer_to_s’:../fbuffer/fbuffer.h:175:47: error: macro 'rb_str_new' requires 2 arguments, but only 1 given../fbuffer/fbuffer.h:175:20: warning: initialization makes integer from pointer without a cast [enabled by default]generator.c: In function ’generate_json’:generator.c:840:25: error: ’rb_cFixnum’ undeclared (first use in this function)generator.c:840:25: note: each undeclared identifier is reported only once for each function it appears ingenerator.c:842:25: error: ’rb_cBignum’ undeclared (first use in this function)generator.c: At top level:cc1: warning: unrecognized command line option '-Wno-self-assign' [enabled by default]cc1: warning: unrecognized command line option '-Wno-constant-logical-operand' [enabled by default]cc1: warning: unrecognized command line option '-Wno-parentheses-equality' [enabled by default]cc1: warning: unrecognized command line option '-Wno-tautological-compare' [enabled by default]make: *** [generator.o] Error 1make failed, exit code 2Gem files will remain installed in /usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.1 for inspection.Results logged to /usr/local/lib/ruby/gems/2.4.0/extensions/x86-linux/2.4.0-static/json-1.8.1/gem_make.out
本人并不太了解ruby,gem,我只是安裝依賴ruby的軟件時(shí)候遇到的。請(qǐng)哪位大神幫忙看一下,該問(wèn)題應(yīng)該怎么解決?還有講講ruby , gem , ruby-rails,bundle之間的關(guān)系!謝謝!
問(wèn)題解答
回答1:json-1.8.1 與 ruby-2.4.0 不兼容,想要順利安裝,可以嘗試一下下面兩個(gè)辦法:
降低 Ruby 的版本。查了一下,1.8.1 已經(jīng)很老了,與 2.2.x 版本不兼容,需要降到 2.1.x 版本。
升級(jí) json 到 1.8.5 版本。執(zhí)行 bundle update json,然后 bundle install。因?yàn)椴恢滥愕?Gemfile 是怎么寫的,無(wú)法確定有沒有明確依賴 1.8.1 版本。所以這個(gè)方法不一定成功。
Ruby 是語(yǔ)言。gem 是一組 Ruby 程序,類似于「包」的概念。RubyGems 是 Ruby 的包管理器,用來(lái)管理和安裝 gems 的。bundle 是用來(lái)管理一個(gè)項(xiàng)目的 gems 的,確保能夠正確地安裝項(xiàng)目依賴,確保能夠運(yùn)行正確的包。
相關(guān)文章:
1. java固定鍵值轉(zhuǎn)換,使用枚舉實(shí)現(xiàn)字典?2. javascript - 移動(dòng)端開發(fā) H5 頁(yè)面在 iOS手機(jī)上無(wú)法實(shí)現(xiàn) 長(zhǎng)按復(fù)制文本 求解決3. 如何解決tp6在zend中無(wú)代碼提示4. java - HTTPS雙向認(rèn)證基礎(chǔ)上有無(wú)必要再進(jìn)行加簽驗(yàn)簽?5. vim - win10無(wú)法打開markdown編輯器6. html - 如何使用用戶輸入的數(shù)據(jù)去運(yùn)行一個(gè)數(shù)學(xué)公式,最后怎么返回。7. python - flask學(xué)習(xí),user_syy添加報(bào)role is invalid keyword for User.8. 這是什么情況???9. css3 - less或者scss 顏色計(jì)算的知識(shí)應(yīng)該怎么學(xué)?或者在哪里學(xué)?10. javascript - 有沒有類似高鐵管家的時(shí)間選擇插件
