9

I tried to run the bundle install command and I got the following errors. After reading some stackoverflow posts, I also ran bundle update.

I am still getting the issue of json ~ 1.8.6 gem (I guess).

An error occurred while installing json (1.8.6), and Bundler cannot continue. Make sure that gem install json -v '1.8.6' succeeds before bundling. Here the issue is not getting installation done properly.

I tried installing gem separately.But still the problem exists.

FAntony
  • 534
  • 7
  • 22
  • try installing gem install json -v '1.8.6' manually in command line first – Haider Ali Mar 29 '18 at 11:59
  • 1
    @TomLord I did the generic way and it worked. Thanks!! – FAntony Mar 30 '18 at 08:45
  • 2
    @HaiderAli Thanks, I've written the answer for it with yours and TomLord 's inputs. Hope this would be effective for others. – FAntony Mar 30 '18 at 09:05
  • Possible duplicate of [Error while installing json gem 'mkmf.rb can't find header files for ruby'](https://stackoverflow.com/questions/20559255/error-while-installing-json-gem-mkmf-rb-cant-find-header-files-for-ruby) – Tom Lord Mar 30 '18 at 12:52

2 Answers2

2

Older versions of json gem have some incompatibilities with newer ruby. Try to update json gem bundle update json

kolas
  • 754
  • 5
  • 16
1

This can be solved by doing the following

1. Installing the ruby development environment by running the following command(for Linux machines).

sudo apt-get install ruby
ruby -e 'puts RUBY_VERSION[/\d+\.\d+/]' -dev

Read this post for more details.

2. Now install the json -v '1.8.6' gem by running the following command.

sudo gem install json -v '1.8.6'

This should solve the issue. Now try running bundle update and bundle install and it should work fine.

Thanks @TomLord and @Haider Ali for your inputs.

Iulian Onofrei
  • 9,188
  • 10
  • 67
  • 113
FAntony
  • 534
  • 7
  • 22