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.rb
creating Makefilecurrent directory:
/home/git/gitlab/vendor/bundle/ruby/2.4.0/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR=" cleancurrent directory:
/home/git/gitlab/vendor/bundle/ruby/2.4.0/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR=" compiling generator.c In 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 in generator.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 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.outAn 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.rb
creating Makefile
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In 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 in
generator.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 1
make failed, exit code 2
Gem 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之间的关系!
谢谢!
天蓬老师2017-04-17 16:25:08
json-1.8.1
은 ruby-2.4.0
과 호환되지 않습니다. 원활하게 설치하려면 다음 두 가지 방법을 시도해 보세요.
루비 버전을 다운그레이드하세요. 확인해 보니 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
의 패키지 관리자로 gem을 관리하고 설치하는 데 사용됩니다. bundle
은 프로젝트의 gem을 관리하여 프로젝트 종속성이 올바르게 설치되고 올바른 패키지가 실행될 수 있도록 하는 데 사용됩니다.