Why Do I Get an Error Installing the JSON Gem in Ubuntu

Why do I get an error installing the JSON gem in Ubuntu?

Installing the ruby1.9.1-dev package should fix this for you:

sudo apt-get install ruby1.9.1-dev

Unable to install json version 1.8.2 gem for Ruby version 2.5.3 on Ubuntu 20.04

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.

Error in installing json 1.8.3 with ruby 2.4.0 on Ubuntu

I think you can solve your problem as:

sudo apt-get install libgmp3-dev

and if above command didn't solve your system, you can try to install this command:

sudo apt-get install libgmp-dev

You can refer at json-1.8.3 Gem::Ext::BuildError

Because 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'

Can't install JSON gem

Why did you run gem install json at all? Bundler takes care of that for you and will ensure that the correct version of each gem is installed (since sometimes dependencies require an older version). Run

gem uninstall json
bundle install

Also ensure you have source 'https://rubygems.org' at the top of your Gemfile.

As for the permissions info, you may have to run gem and bundle commands with sudo.

By the way, I highly recommend taking a look at and using RVM, particularly the gemsets feature. It will make your life infinitely better when developing Ruby apps. If you decide to do so, I'd also suggest trashing all the gems you've install using the system Ruby by running sudo rm -rf /Library/Ruby/Gems/1.8/. It's also important that when using RVM you don't have to use sudo when running gem (or bundle), which is not only safer but less typing too.

Why won't bundler install JSON gem?

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'

Can't install json gem 1.8.6 - failed to build gem native extension on Ubuntu

It seems that there is similar problem on RedHat 7.

In case of Ubuntu, the solution seems to be installing ruby-dev package.

sudo apt-get install ruby-dev



Related Topics



Leave a reply



Submit