rails: Component 'json' of Ruby on Rails not working with Ruby 2.4.0
Install Ruby 2.4.0 In projects with RoR 3.2.xx, 4.2.xxx bundle install is fail:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/ruby/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
/home/ruby/.rbenv/versions/2.4.0/bin/ruby -r ./siteconf20161225-17221-ivjmjg.rb extconf.rb creating Makefile
current directory: /home/ruby/.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/ruby/.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: ошибка выполнения рецепта для цели «generator.o» make: *** [generator.o] Ошибка 1
make failed, exit code 2
Gem files will remain installed in /home/ruby/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/json-1.8.3 for inspection. Results logged to /home/ruby/.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.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 30
- Comments: 17 (4 by maintainers)
Commits related to this issue
- update json gem to support ruby 2.4 See https://github.com/rails/rails/issues/27450 — committed to crest-cassia/oacis by yohm 7 years ago
- Update Gemfile for json 1.8.6 Version 1.8.3 had an error and was not compiling on macOS. See https://github.com/rails/rails/issues/27450 — committed to wmde/fundraising-browsertests by gbirke 7 years ago
- Gemfile: update json gem to 1.8.6 so it can compile with Ruby 2.4 See thread here: https://github.com/rails/rails/issues/27450 — committed to hlian/mixtapes by hlian 7 years ago
- update rails for ruby 2.4 per https://github.com/rails/rails/issues/27450 — committed to bjamesvDatica/ruby-example-app by bjamesvDatica 5 years ago
- Lock to JSON 1.8.5 https://github.com/rails/rails/issues/27450#issuecomment-272148454 — committed to rrn/acts_as_sourceable by alexdunae 2 years ago
@Drenmi gem json -v 1.8.5 is perfectly support it! On both RoR - 3.2.xx and 4.2.xx Only with
gem 'json', github: 'flori/json', branch: 'v1.8'
For many projects - is problem edit each GemfileCan still easier to fix this dependence in RoR?
It has just been published 👍
It’s also failing for RoR 5.0.1.
Same issue here with gem ‘github-pages’, trying to install json…
Solved my issue by downgrading to ruby 2.3 using this :
from : https://gorails.com/setup/osx/10.12-sierra
Thanks for the helpful comments. Editing Gemfile.lock and changing json’s version from 1.8.3 to 1.8.5 fixed the issue for me. After that I could run
bundle install
without getting this error.I got another error of course, but no longer this one. 😆
Solved: I just commented out, in my
Gemfile
, the offending gem,sdoc (~> 0.4.0)
which resolved to 0.4.0 and depended onjson (~> 1.8)
… and re-runbundle update
all right…With Rails 5.0.1 & ruby 2.4.0, when doing
bundle update
(orgem install json -v '1.8.3'
) :Gem::Ext::BuildError: ERROR: Failed to build gem native extension. [...] error: ‘rb_cFixnum’ undeclared (first use in this function) [...] error: ‘rb_cBignum’ undeclared (first use in this function)
The JSON gem only supports the
Integer
unification in Ruby 2.4 starting from 2.0.0, and the Rails dependency is set to~> 1.8
, so you won’t be able to run Rails 4.2 with Ruby 2.4 for now.It looks like this commit fixes it so we only have to wait for the next release. https://github.com/rails/rails/commit/47c49242913abbcdb8f798f53324769892d18c97
How about RoR 4.2.x.x? Any plans for releasing a fix to support Ruby 2.4 ?