Error when installing json 1.7.5 in rails - ruby-on-rails

I am trying to install latest version of json using gem bundle install and it results in an error. I am trying to install within aptana studio 3 workspace.
I get the following error - can anyone throw some light on this issue -
Installing json (1.7.5) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
An error occurred while installing json (1.7.5), and Bundler cannot continue.
Make sure that gem install json -v '1.7.5' succeeds before bundling.
After seeing this error I just ran install json and it runs fine but json doesnt seem to install.
--
Sandesh

I had the same json 1.7.5 error while creating or doing bundle install on a new rails 3.2.9 app on ruby 1.9.3. This is what worked for me:
Get the latest version of Xcode (4.5.2 in my case). Open up Xcode. Go to Preferences. Go to downloads, and click INSTALL on the Command Line Tools.
In your terminal do: rvm reinstall 1.9.3
Create your new rails app, you will get the same json 1.7.5 error, but it's ok. Then open up the app and go to your Gemfile. At the top of the file, change source 'https://rubygems.org' to source 'http://rubygems.org'
run gem install json -v '1.7.5'
run bundle install
This should work, as it did in my case!

I forgot about it sorry. Please check these questions:
When I try sudo gem install json I get the following error
Why won't bundler install the json 1.7.4 gem on OS X 10.8?
Probably you need to install XCode Command Line tools.

Related

An error occurred while installing json (1.8.6), and Bundler cannot continue

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.
Older versions of json gem have some incompatibilities with newer ruby. Try to update json gem bundle update json
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.

Windows 10 Ruby on Rails Install Issue Json

Hello I am trying set up ruby on rails on my pc. Everytime i do a bundle install, I receive this error
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that gem install json -v '1.8.3' succeeds before bundling.
I am trying to use ruby 2.2.3, This is my first experience using Ruby on my pc.
Some gems need to build some native C/C++ extensions. You should install DevKit. Here's the link. And then add it to your system environment's path variable.

Installing Bundle for Ruby

I am trying to install bundle and I keep on getting errors about specific gems not being installed. For example, my byebug debugger was not installed I had to install that, and my eventmachine was not installed, and now my json is not installed I install json and when I run
#bundle install
I still get the:
An error occurred while installing json (1..7.7), and Bundler cannot continue.
Make sure that 'gem install json -v '1.7.7' succeeds before bundling
How can I successfully install bundle?
edit: gem install json -v '1.7.7' I get the following error:
new error message

after entering 'bundle install' on command line I get "make sure that 'gem install json -v 1.8.2' succeeds before bundling"

I've been following this lynda tutorial online on 'Ruby on Rails.' I've downloaded Ruby, devkit and rails on to my computer. After I created sample_app and tried to run bundle install, but it keeps telling me make sure that 'gem install json -v 1.8.2' succeeds before bundling" I try to run gem install json -v 1.8.2 and other variations including "gem install json -v 1.8.2 --verbose", "gem install json --platform=ruby" but everytime I get an error saying that it failed to build gem native extensions. The same thing happened when I was following the downloading devkit tutorial and I tried to install JSON as per its instructions. I've tried using gem update system 2.3.0 but that doesn't work either. What could be wrong?
Typically this will happen on Windows because not all the commands are availible. I would recommended that you either use VirtualBox with an Ubuntu image or use Cloud9 IDE.
I just experienced the same problem myself. I am working my way from Windows to a Mac but not quite there just yet. Windows is ok for Rails development (been doing so for 3 years) although it does present some unique issues occasionally. Check out the following link to downgrade RubyGems to 1.8.29 and then try running bundle install again.
Issue with Ruby gem install

Why won't bundler install JSON gem?

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.
$ bundle update json
$ bundle install
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'
Run this command then everything will be ok
sudo apt-get install libgmp-dev
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!
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.
I found the solution here. There is a problem with json version 1.8.1 and ruby 2.2.3, so install json 1.8.3 version.
gem install json -v1.8.3
You should try
$ sudo gem install json -v '1.8.2'
in my case (Ubuntu 14.04) that didn't work directly and I had to do this:
$ sudo apt-get install ruby-dev
and then I could install the gem and continue. Had one more problem that was fixed by:
$ sudo apt-get install libsqlite3-dev
Hoping helps.
If the recommended answer didn't help because you are already using a newer version of bundler. Try the solution that worked for me.
Delete everything inside your vendor folder.
Add a line to your gemfile
gem 'json', '1.8.0'
Then run - bundle update json.
It seems to be an issue with 1.8.1 so going back to 1.8.0 did the trick for me.
I ran into this error while trying to get a project to run on my local dev box (OSX 10.6), using Sinatra and Postgresql (through activerecord), running on an rvm'd ruby 2.1. I found my answer here: https://github.com/wayneeseguin/rvm/issues/2511
My exact problem (after the first block of log entries):
I also get an error when trying to build native extensions for gems
The answer:
rvm reinstall 2.1.0 --disable-binary
The explanation:
OSX does not have a package manager so all libraries have to be installed manually by user, this makes it virtually impossible to link the binary dynamically, and as you can see there are problems with the (pseudo)statically linked binary.
For the sake of completeness, I had first forgotten to update rvm (rvm get head), which yielded some other errors, but still needed the --disable-binary flag once I had done so.
bundle update json. Helped to get through.
When I tried to install the json gem using gem install json separate from just using bundle install I got ERROR: Failed to build gem native extension., looking that up I found using
apt-get install ruby-dev
did the trick
For OS X make sure you have coreutils
$ brew install coreutils
$ bundle
This appears to be a bug in Bundler not recognizing the default gems installed along with ruby 2.x. I still experienced the problem even with the latest version of bundler (1.5.3).
One solution is to simply delete json-1.8.1.gemspec from the default gemspec directory.
rm ~/.rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/specifications/default/json-1.8.1.gemspec
After doing this, bundler should have no problem locating the gem. Note that I am using chruby. If you're using some other ruby manager, you'll have to update your path accordingly.
I was missing C headers solution was to download it for Xcode, this is the best way.
xcode-select --install
Hope it helps.
Bundle was failing to install json -v '1.8.1' and deleting my Gemfile.lock and running bundle again solved this issue for me.
I installed the latest version of json:
gem install json
Then deleted the line json(1.8.1) from the Gemfile.lock and did a
bundle install
And then the Gemfile.lock file uses json(1.8.3) without erros
Switch ruby version from 1.9 to 2.2 with rvm did the job for me
For me, some of the answers mentioned earlier were helpful from understanding point of view, but those didn't solve my problem.
So this is what I did to solve issue.
Modified gemfile.lock to update json (2.0.2) (Earlier, it was 1.8.3)
Check the Bundler version installed (Bundler -v command). I had version 1.12.5 installed
Install bundler version 1.11.2 (using gem install bundler -v '1.11.2')
Then run bundle install
For macOS Sierra:
I ran into this error When i used bundler(v1.15.3) in Rails(v4.2) project.
The solution for me is gem uninstall bundler -v '1.15.3' and gem install bundler -v '1.14.6'.

Resources