Alexander Kozachenko
Alexander Kozachenko

Reputation: 945

Ruby On Rails: Bundler could not find compatible versions for gem "json"

I did search and none of the existing solutions worked for me, so I created a new question.

Got an error trying to launch the server.

Bundler could not find compatible versions for gem "json":
In snapshot (Gemfile.lock):
json (= 1.8.6)

In Gemfile: rails (= 4.2.4) x86-mingw32 was resolved to 4.2.4,
which depends on activesupport (= 4.2.4) x86-mingw32 was resolved to 4.2.4,
which depends on json (>= 1.7.7, ~> 1.7) x86-mingw32

Gemfile source 'https://rubygems.org'

 gem 'rails', '4.2.4'
 gem 'activerecord-jdbcpostgresql-adapter'
 gem 'sass-rails', '~> 5.0'
 gem 'uglifier', '>= 1.3.0'
 gem 'coffee-rails', '~> 4.1.0'
 gem 'therubyrhino'
 gem 'jquery-rails'
 gem 'jbuilder', '~> 2.0'
 gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Gemfile.lock fragment

 GEM
   remote: https://rubygems.org/
   specs:
  activesupport (4.2.4)
       i18n (~> 0.7)
       json (~> 1.7, >= 1.7.7)
       minitest (~> 5.1)
       thread_safe (~> 0.3, >= 0.3.4)
       tzinfo (~> 1.1)

  json (1.8.6-java)

What I tried to do:

Bundler could not find compatible versions for gem "json": In snapshot (Gemfile.lock):
json (= 1.8.6)

In Gemfile:
rails (= 4.2.4) x86-mingw32 was resolved to 4.2.4,
which depends on activesupport (= 4.2.4) x86-mingw32 was resolved to 4.2.4,
which depends on json (= 1.8.6) x86-mingw32

Delete json (1.8.6-java) from Gemfile.lock

None of these worked.

Upvotes: 4

Views: 3078

Answers (3)

rwold
rwold

Reputation: 2476

Unfortunately I don't have enough rep to comment with a question, so I can't ask what version of json you specified when you added it to your gemfile explicitly or whereabouts in the gemfile you specified it (see this SO thread). But my best guess is that one of your other dependencies is downloading 1.8.6, which is not consistent with version ~>1.7.7 specified by your version of Active Support.

My suggestion would be to try and explicitly require

json (~> 1.7, >= 1.7.7)

at the end of your gemfile, before something else loads it. If something else is trying to load a more recent version of json, you should get a different error message; you may have to then specify an earlier version of the gem trying to download a conflicting version.

Upvotes: 2

Veeresh Honnaraddi
Veeresh Honnaraddi

Reputation: 1051

When you run bundle update to update your gems, it updates all of them at once. If your app stops working or your tests start failing, it can be pretty hard to figure out which gem update broke it.

You might think bundle update gem_name would just update that gem and its dependencies .

Note: bundle update --source gem_name Updates exclusively the gem

Upvotes: 0

DevMasterAryan
DevMasterAryan

Reputation: 71

Just do

bundle update

It works for me

Upvotes: 0

Related Questions