How to: Fix json 1.8.3 with Ruby 2.5

Posted . Visible to the public.

The gem json fails to install for Ruby 2.5 if you use a version equal or below 1.8.3.

Run bundle update json --conservative to solve this issue.

The backtrace you will encounter looks like this:

Building native extensions. This could take a while...
ERROR:  Error installing json:
	ERROR: Failed to build gem native extension.

    current directory: /home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/json-1.8.3/ext/json/ext/generator
/home/user/.rbenv/versions/2.5.3/bin/ruby -I /home/user/.rbenv/versions/2.5.3/lib/ruby/site_ruby/2.5.0 -r ./siteconf20190619-30569-s2y487.rb extconf.rb
creating Makefile

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

current directory: /home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.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); did you mean ‘mFixnum’?
     } else if (klass == rb_cFixnum) {
                         ^~~~~~~~~~
                         mFixnum
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); did you mean ‘rb_cFixnum’?
     } else if (klass == rb_cBignum) {
                         ^~~~~~~~~~
                         rb_cFixnum
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’
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/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/json-1.8.3 for inspection.
Results logged to /home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0-static/json-1.8.3/gem_make.out
Last edit
Emanuel
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2019-06-19 14:42)