[Solved] JSON 1.8.3 is not compatible with ruby 2.4 preview

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

    current directory: /home/siva/.rvm/gems/ruby-2.4.0-preview2/gems/json-1.8.3/ext/json/ext/generator
/home/siva/.rvm/rubies/ruby-2.4.0-preview2/bin/ruby -r ./siteconf20160913-31695-1hgh0cs.rb extconf.rb
creating Makefile

current directory: /home/siva/.rvm/gems/ruby-2.4.0-preview2/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /home/siva/.rvm/gems/ruby-2.4.0-preview2/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" [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 /home/siva/.rvm/gems/ruby-2.4.0-preview2/gems/json-1.8.3 for inspection.
Results logged to /home/siva/.rvm/gems/ruby-2.4.0-preview2/extensions/x86_64-linux/2.4.0/json-1.8.3/gem_make.out

Because of this I couldn't upgrade my rails 4.2.5 app as I am getting this error

Bundler could not find compatible versions for gem "json":
  In Gemfile:
    json (~> 2.0.2)

    rails (= 4.2.5) was resolved to 4.2.5, which depends on
      activerecord (= 4.2.5) was resolved to 4.2.5, which depends on
        activesupport (= 4.2.5) was resolved to 4.2.5, which depends on
          json (>= 1.7.7, ~> 1.7)

    uglifier (>= 1.0.3) was resolved to 2.7.2, which depends on
      json (>= 1.8.0)

As per my knowledge this issue has been raised because of ruby unification integer.

Asked Jan 07 '22 23:01
avatar sivagollapalli
sivagollapalli

6 Answer:

Running into the same issues. Happy to provide any additional information if it would be helpful.

1
Answered Sep 13 '16 at 15:15
avatar  of jerhinesmith
jerhinesmith

@alepore that's not doable if you're stuck on Rails 4.2.x - for example from my Gemfile.lock

    activesupport (4.2.7.1)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
1
Answered Dec 13 '16 at 16:50
avatar  of rhymes
rhymes

Could it be possible to backport the integer unification commit? https://github.com/flori/json/commit/8e16a607f9abbd24dba508ba5c92877410cecfd7

1
Answered Dec 25 '16 at 02:58
avatar  of rhymes
rhymes

In case it matters, aws-sdk-v1 depends on ~> json 1.4, and upgrading to aws-sdk v2 is a major project we hope to do later next year.

This json incompatibility blocks us from going to ruby 2.3 to 2.4 today :\

1
Answered Dec 25 '16 at 20:31
avatar  of esilverberg
esilverberg

@rhymes I already removed json dependency on 4-2-stable branch of rails/rails. see https://github.com/rails/rails/pull/26334

You can use Ruby 2.4.0 with Rails 4.2.8 that is next minor release.

1
Answered Dec 26 '16 at 13:00
avatar  of hsbt
hsbt

I've never seen such a complicated to get working language. For God sake !!! Thru the years I've used apt, rvm, rbenv, chruby ..... nightmare. Always spending much more time setting up than developing !!!

1
Answered Jan 02 '17 at 21:30
avatar  of zirikatzaile
zirikatzaile