Why won't bundler install JSON gem?
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.
Related videos on Youtube
Thomas
Updated on July 08, 2020Comments
-
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
andrvm 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 over 10 yearsWhat
bundle show json
gives you? -
user2503775 over 10 yearsAdd
gem json, '1.8.1'
to Gemfile -
Thomas over 10 yearsI have gem json, '1.8.1' in my gemfile already unfortunately
-
Thomas over 10 yearsbundle show json give /Users/ME/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/json-1.8.1
-
e9t about 8 yearsI needed
sudo apt-get install ruby-dev
on my Ubuntu. -
Stefan Lyew about 8 yearsgem 'json', '1.8.1' <--- need single quotes
-
-
Jason Denney over 10 yearsHad 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 about 10 yearsGet 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 about 10 yearsYou 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 the2.1.0
mentioned above. -
Obie almost 10 years
gem install json -v '1.8.1'
followed bybundle package
did the trick for me -
Catfish over 9 yearsSaved me a few swear words. Thanks for this!
-
Snowcrash over 9 yearsIsn'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 almost 9 yearsyup, it's simple to solve a problem with json bundle. Thank you
-
Pramod Shinde over 8 yearsThis did not worked for me, sudo apt-get install libgmp3-dev worked , found solution github.com/flori/json/issues/253
-
Loubot over 8 yearsWorked when upgrading from ruby 2.0.0 to 2.2.4.
-
Deepak Kumar Padhy about 8 yearsWorked for me too :) Thanks!
-
Joffrey Baratheon about 8 yearsNo need to delete everything. "bundle update json" sufficed.
-
Rcordoval almost 8 years@Imran You have to put this on a linux terminal. I guess you are running windows?
-
fuzzygroup over 7 yearsThis 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 over 7 yearsWorked fine, first of all I delete the
Gemfile.lock
and then just runbundle install
and that's it. -
Francis Malloch over 7 yearsJust running a bundle update solved this issue for me... in other words using a newer JSON gem build.
-
Simon Liu about 7 yearsSuccessfully installed json 1.8.6 (was 1.8.3)
-
Echelon about 7 yearsThank you, that saved me a lot of frustration!
-
Catfish about 7 yearsI'm using bundler version 1.14.6 and also getting this error
-
Windmill almost 7 yearsThis did it for me on Ruby 2.4.0!
-
Aleksey Deryagin almost 7 yearsWorks for rbenv ruby 2.4.1 too (debian / ubuntu)
-
etagwerker over 6 yearsUsing
gem 'json', '1.8.6'
worked for me. You might want to try that. -
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 over 6 yearsThis worked for me as well. Ruby 2.4.0 High Sierra. Thank you!
-
eebbesen over 6 years
bundle update
will update all your gems.gem update bundler
will update bundler. -
fatihturan about 6 yearsWorked for me too under Ruby version 2.4.2p198. Thanks.
-
Scott Lawrence about 6 yearsI 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 almost 6 yearsamazing - you saved my day!
-
Pramod Shinde about 4 yearsOn MAC
bundle update json
worked it updated to 1.8.6 from 1.8.3 -
Paul Verschoor over 3 yearsAlthough I got a warning "Warning: coreutils 8.32 is already installed and up-to-date", this did the trick.