mysql - 安装gem报错
问题描述
1.相应的环境: ubuntu12.04 ruby 2.4 2.通过
bundle install --deployment --without development test postgres aws
安装gem的时候报错:
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.
于是我就手动安装了gem install json -v ’1.8.1’ ,依然报错:
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的软件时候遇到的。请哪位大神帮忙看一下,该问题应该怎么解决?还有讲讲ruby , gem , ruby-rails,bundle之间的关系!谢谢!
问题解答
回答1:json-1.8.1 与 ruby-2.4.0 不兼容,想要顺利安装,可以尝试一下下面两个办法:
降低 Ruby 的版本。查了一下,1.8.1 已经很老了,与 2.2.x 版本不兼容,需要降到 2.1.x 版本。
升级 json 到 1.8.5 版本。执行 bundle update json,然后 bundle install。因为不知道你的 Gemfile 是怎么写的,无法确定有没有明确依赖 1.8.1 版本。所以这个方法不一定成功。
Ruby 是语言。gem 是一组 Ruby 程序,类似于「包」的概念。RubyGems 是 Ruby 的包管理器,用来管理和安装 gems 的。bundle 是用来管理一个项目的 gems 的,确保能够正确地安装项目依赖,确保能够运行正确的包。
相关文章:
1. javascript - 如何在windows下搭建react开发环境上,实现网站的react版本2. 数据库创建失败3. PHP类中的$this4. javascript - 关于圣杯布局的一点疑惑5. css3 - 一篇文章有好多段 怎么控制整篇文章显示多少行 剩余省略 而不是每段控制6. python - 有一个函数名(字符串形式),如何能够调用这个函数?7. vue.js - weex scroller搭配refresh在android平台上拉会触发refresh8. javascript - 在html中写了个<video>视频,浏览器却是一片空白为什么呢?360浏览器?9. node.js - 使用npm安装vue-cli后,vue还是不可用是什么原因?10. css3 - Firefox 字号相对IE、Chrome更大,如何在CSS中统一?