Ruby on rails 在Ubuntu上安装json 1.8.3和ruby 2.4.0时出错

Ruby on rails 在Ubuntu上安装json 1.8.3和ruby 2.4.0时出错,ruby-on-rails,json,ruby,ubuntu,Ruby On Rails,Json,Ruby,Ubuntu,我试图在我的本地机器(Ubuntu 15.10)上运行一个开源web应用程序。当我运行bundle命令时,我得到了 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /home/yesh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator /home/yesh/.r

我试图在我的本地机器(Ubuntu 15.10)上运行一个开源web应用程序。当我运行
bundle
命令时,我得到了

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/yesh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
/home/yesh/.rbenv/versions/2.4.0/bin/ruby -r ./siteconf20170310-4319-tlc92v.rb
extconf.rb
creating Makefile

current directory:
/home/yesh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR=" clean

current directory:
/home/yesh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR="
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’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
cc1: warning: unrecognized command line option ‘-Wno-tautological-compare’
Makefile:241: recipe for target 'generator.o' failed
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in
/home/yesh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/json-1.8.3 for
inspection.
Results logged to
/home/yesh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/json-1.8.3/gem_make.out

An error occurred while installing json (1.8.3), and Bundler cannot
continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.

因此,我尝试了
gem安装json-v'1.8.3'
,但再次收到与上面相同的错误消息。请帮助解决此问题。

您的Ruby版本似乎与Project的Ruby版本不同。JSON只支持Ruby中的
Integer
从v统一。2.0.0. 以及以上-可能列出的一些gem依赖于
json(~>1.8)
。要么在
Gemfile
中注释掉这个gem,然后运行
bundle安装
,要么降级Ruby

我认为您可以通过以下方式解决您的问题:

sudo apt-get install libgmp3-dev
如果上述命令无法解决您的系统问题,您可以尝试安装此命令:

sudo apt-get install libgmp-dev
你可以访问

因为您的ruby版本是
2.4.0
。ruby版本与
json 1.8.3
不兼容。您可以尝试在文件中添加此行:

gem 'json', github: 'flori/json', branch: 'v1.8'

我试过这两个,但没有work@YeshwanthVenkatesha我更新了我的答案,请再次检查。这很有效。多谢各位@YeshwanthVenkatesha如果我的回答帮助你解决了你的问题,请记下来。谢谢。它确实很管用。非常感谢。在Gemfile中评论这行行不通。也许我将不得不降级Ruby/