I am trying to run a rails server and when I run the bundle install
command, I get the following error:
An error occurred while installing json (1.8.3), and Bundler cannot
continue.
Make sure that `gem install json -v '1.8.3' --source 'https://rubygems.org/'`
succeeds before bundling.
When I run the recommended command gem install gem install json -v '1.8.3' --source 'https://rubygems.org/'
, I get error building native extensions
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: /home/user/.rvm/gems/ruby-2.5.3/gems/json-1.8.3/ext/json/ext/generator
/home/user/.rvm/rubies/ruby-2.5.3/bin/ruby -I /home/user/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210822-103903-1kc2ys9.rb extconf.rb
creating Makefile
current directory: /home/user/.rvm/gems/ruby-2.5.3/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /home/user/.rvm/gems/ruby-2.5.3/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’?
861 | } 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 ‘mBignum’?
863 | } else if (klass == rb_cBignum) {
| ^~~~~~~~~~
| mBignum
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’
make: *** [Makefile:242: generator.o] Error 1
make failed, exit code 2
I don't know how do I go about solving this, any help would be much appreciated
CodePudding user response:
You are trying to install a very old version of gem json
from 2015.
This gem, depends on some ruby headers like Bignum which was removed on recent versions of ruby.
Try to install a more recent version of this gem like:
gem install json -v '2.5.1' --source 'https://rubygems.org/'
Or, you can try to downgrade your ruby version to 2.3.0 and try to install the json version on 1.8.3.