[版本信息]
ruby 2.4.0p0(2016-12-24修订版57164)[x86_64-linux]/gem 2.0.3/Windows 10
我跑了bundle install
,它告诉我跑gem install json -v '1.8.3'
我这样做了,并且无法构建gem原生扩展错误.
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/home/ec2-user/.rvm/rubies/ruby-2.4.0/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
generator.c: In function ‘generate_json’:
generator.c:861:25: error: ‘rb_cFixnum’ undeclared (first use in this function)
} else if (klass == rb_cFixnum) {
^
generator.c:861:25: note: each undeclared identifier is reported only once for each function it appears in
generator.c:863:25: error: ‘rb_cBignum’ undeclared (first use in this function)
} else if (klass == rb_cBignum) {
^
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
Gem files will remain installed in /home/ec2-user/.rvm/gems/ruby-2.4.0/gems/json-1.8.3 for inspection.
Results logged to /home/ec2-user/.rvm/gems/ruby-2.4.0/gems/json-1.8.3/ext/json/ext/generator/gem_make.out
Run Code Online (Sandbox Code Playgroud)
我检查过几个文件.我安装了Devkit和json 1.8.5,但我的项目保留了"安装json 1.8.3"的消息我怎样才能解决这个问题?
/home/ec2-user/.rvm/gems/ruby-2.4.0/gems/json-1.8.3
包含:
../
./
data/
diagrams/
ext/
java/
lib/
tests/
tools/
install.rb*
.gitignore
.travis.yml
CHANGES
COPYING
COPYING-json-jruby
GPL
Gemfile
README-json-jruby.markdown
README.rdoc
Rakefile
Run Code Online (Sandbox Code Playgroud)
/home/ec2-user/.rvm/gems/ruby-2.4.0/gems/json-1.8.3/ext/json/ext/generator/gem_make.out
包含:
user/.rvm/gems/ruby-2.4.0/gems/json-1.8.3/ext/json/ext/generator/gem_make.out
/home/ec2-user/.rvm/rubies/ruby-2.4.0/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
generator.c: In function ‘generate_json’:
generator.c:861:25: error: ‘rb_cFixnum’ undeclared (first use in this function)
} else if (klass == rb_cFixnum) {
^
generator.c:861:25: note: each undeclared identifier is reported only once for each function it appears in
generator.c:863:25: error: ‘rb_cBignum’ undeclared (first use in this function)
} else if (klass == rb_cBignum) {
^
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
Run Code Online (Sandbox Code Playgroud)
小智 19
尝试删除Gemfile.lock并再次运行bundle命令.它应该使用不同版本的json(即1.8.6)而没有问题.
Oma*_*eth 16
我最近也遇到了同样的问题,试着看看你使用的任何宝石的新版本是否依赖于json 1.8.3.这是因为Ruby 2.4将Fixnum和Bignum统一为Integer.如果你能够升级到json 1.8.5或更高版本,它应该有助于解决你的问题.
您也可以尝试更新您正在使用的gem,并尝试放宽版本限制(我发现这适用于很多项目,但不是全部),如下所示:
gem 'json', '>= 1.8'
Run Code Online (Sandbox Code Playgroud)