Posted 2 months ago. Visible to the public.

How to: Fix json 1.8.3 with Ruby 2.5

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:

Copy
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

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Emanuel De
Last edit:
2 months ago
by Emanuel De
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Emanuel De to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more