Why won't bundler install JSON gem?

120,206

Solution 1

So after a half day on this and almost immediately after posting my question I found the answer. Bundler 1.5.0 has a bug where it doesn't recognize default gems as referenced here

The solution was to update to bundler 1.5.1 using gem install bundler -v '= 1.5.1'

Solution 2

$ bundle update json
$ bundle install

Solution 3

Run this command then everything will be ok

sudo apt-get install libgmp-dev

Solution 4

if you are in MacOS Sierra and your ruby version is 2.4.0.The ruby version is not compatible with json 1.8.3.

You can try add this line in your Gemfile:

gem 'json', github: 'flori/json', branch: 'v1.8'

This works for me!

Solution 5

To solve this problem, simply run:

bundle update

It will update the version of your bundler. Then run:

bundle install

Your problem will get solve. Solution is well explained here.

Share:
120,206

Related videos on Youtube

Thomas
Author by

Thomas

Updated on July 08, 2020

Comments

  • Thomas
    Thomas almost 4 years

    I get the following error when attempting to run cap production deploy.

    DEBUG [dc362284]    Bundler::GemNotFound: Could not find json-1.8.1.gem for installation
    DEBUG [dc362284]    An error occurred while installing json (1.8.1), and Bundler cannot continue.
    DEBUG [dc362284]    Make sure that `gem install json -v '1.8.1'` succeeds before bundling.
    

    It may be important to note that this deployment was working, than I upgraded to Ruby 2.1.0 to remove an encoding error. I upgraded locally which worked fine. I ran rvm install 2.1.0 and rvm use 2.1.0 then changed my .ruby-version file to reflect this Ruby upgrade.

    The bundle install command works locally, but produces the same above error when I ssh onto the destination server and run this command.

    If I run gem list I can see this in the list of gems.

    ...
    jquery-rails (3.0.4)
    json (1.8.1)
    less (2.3.2)
    ...
    

    If I try the recommended solution gem install json -v '1.8.1' Locally and on the destination server I get the following output:

    Building native extensions.  This could take a while...
    Successfully installed json-1.8.1
    Parsing documentation for json-1.8.1
    Done installing documentation for json after 0 seconds
    1 gem installed
    

    So it appears the gem is installed, right? Why is this happening? How can I solve this? Any help would be greatly appreciated.

    • user2503775
      user2503775 over 10 years
      What bundle show json gives you?
    • user2503775
      user2503775 over 10 years
      Add gem json, '1.8.1' to Gemfile
    • Thomas
      Thomas over 10 years
      I have gem json, '1.8.1' in my gemfile already unfortunately
    • Thomas
      Thomas over 10 years
      bundle show json give /Users/ME/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/js‌​on-1.8.1
    • e9t
      e9t about 8 years
      I needed sudo apt-get install ruby-dev on my Ubuntu.
    • Stefan Lyew
      Stefan Lyew about 8 years
      gem 'json', '1.8.1' <--- need single quotes
  • Jason Denney
    Jason Denney over 10 years
    Had the same issue even after updating bundler, doing a gem install json -v '1.8.1' after updating fixed the error message for me.
  • holyredbeard
    holyredbeard about 10 years
    Get the following error with your solution: "Version '2.1.0' is ambiguous. Cannot select Ruby implementation/version, please be more specific. Cannot reinstall unknown package ''"
  • Matthias
    Matthias about 10 years
    You might not have ruby 2.1.0, or more than one version installed through rvm. Run rvm list, and you'll see what is your current version. Use the full string (e.g. ruby-2.0.0-p451) instead of the 2.1.0 mentioned above.
  • Obie
    Obie almost 10 years
    gem install json -v '1.8.1' followed by bundle package did the trick for me
  • Catfish
    Catfish over 9 years
    Saved me a few swear words. Thanks for this!
  • Snowcrash
    Snowcrash over 9 years
    Isn't bundler supposed to install these gems for you? I don't understand why you have to install the gems manually. bundler.io/rationale.html I'm using Bundler version 1.7.11
  • Hai Nguyen
    Hai Nguyen almost 9 years
    yup, it's simple to solve a problem with json bundle. Thank you
  • Pramod Shinde
    Pramod Shinde over 8 years
    This did not worked for me, sudo apt-get install libgmp3-dev worked , found solution github.com/flori/json/issues/253
  • Loubot
    Loubot over 8 years
    Worked when upgrading from ruby 2.0.0 to 2.2.4.
  • Deepak Kumar Padhy
    Deepak Kumar Padhy about 8 years
    Worked for me too :) Thanks!
  • Joffrey Baratheon
    Joffrey Baratheon about 8 years
    No need to delete everything. "bundle update json" sufficed.
  • Rcordoval
    Rcordoval almost 8 years
    @Imran You have to put this on a linux terminal. I guess you are running windows?
  • fuzzygroup
    fuzzygroup over 7 years
    This worked fantastically for me on OSX, Ubuntu across multiple bad versions of the json gem. In one case I had to delete the lock file and rebuild from scratch: git rm Gemfile.lock bundle install
  • alexventuraio
    alexventuraio over 7 years
    Worked fine, first of all I delete the Gemfile.lock and then just run bundle install and that's it.
  • Francis Malloch
    Francis Malloch over 7 years
    Just running a bundle update solved this issue for me... in other words using a newer JSON gem build.
  • Simon Liu
    Simon Liu about 7 years
    Successfully installed json 1.8.6 (was 1.8.3)
  • Echelon
    Echelon about 7 years
    Thank you, that saved me a lot of frustration!
  • Catfish
    Catfish about 7 years
    I'm using bundler version 1.14.6 and also getting this error
  • Windmill
    Windmill almost 7 years
    This did it for me on Ruby 2.4.0!
  • Aleksey Deryagin
    Aleksey Deryagin almost 7 years
    Works for rbenv ruby 2.4.1 too (debian / ubuntu)
  • etagwerker
    etagwerker over 6 years
    Using gem 'json', '1.8.6' worked for me. You might want to try that.
  • twknab
    twknab over 6 years
    +1 Really helpful and got me unstuck. After bundle update, the install worked great. Thank you for the clean solution.
  • Robert_T_Taylor
    Robert_T_Taylor over 6 years
    This worked for me as well. Ruby 2.4.0 High Sierra. Thank you!
  • eebbesen
    eebbesen over 6 years
    bundle update will update all your gems. gem update bundler will update bundler.
  • fatihturan
    fatihturan about 6 years
    Worked for me too under Ruby version 2.4.2p198. Thanks.
  • Scott Lawrence
    Scott Lawrence about 6 years
    I upvoted this answer because it worked for me while the accepted answer did not. Like @Robert_T_Taylor, I ran this on macOS High Sierra.
  • Unkas
    Unkas almost 6 years
    amazing - you saved my day!
  • Pramod Shinde
    Pramod Shinde about 4 years
    On MAC bundle update json worked it updated to 1.8.6 from 1.8.3
  • Paul Verschoor
    Paul Verschoor over 3 years
    Although I got a warning "Warning: coreutils 8.32 is already installed and up-to-date", this did the trick.