12

I've just started to have a look at ruby on rails and can't get a server to run. I'm running ruby 2.3.0 and rails 4.2.5 and after I have a new rail projects I try to run bin/rails server but get the following error:

Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring. /Users/John/.rvm/gems/ruby-head/gems/json-1.8.3/lib/json/ext.rb:13:in `require': incompatible library version - /Users/John/.rvm/gems/ruby-head/gems/json-1.8.3/lib/json/ext/parser.bundle (fatal) from /Users/John/.rvm/gems/ruby-head/gems/json-1.8.3/lib/json/ext.rb:13:in `<module:Ext>' from /Users/John/.rvm/gems/ruby-head/gems/json-1.8.3/lib/json/ext.rb:12:in `<module:JSON>' from /Users/John/.rvm/gems/ruby-head/gems/json-1.8.3/lib/json/ext.rb:9:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/json-1.8.3/lib/json.rb:58:in `require' from /Users/John/.rvm/gems/ruby-head/gems/json-1.8.3/lib/json.rb:58:in `<module:JSON>' from /Users/John/.rvm/gems/ruby-head/gems/json-1.8.3/lib/json.rb:54:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/activesupport-4.2.5/lib/active_support/core_ext/object/json.rb:2:in `require' from /Users/John/.rvm/gems/ruby-head/gems/activesupport-4.2.5/lib/active_support/core_ext/object/json.rb:2:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/activesupport-4.2.5/lib/active_support/core_ext/object.rb:12:in `require' from /Users/John/.rvm/gems/ruby-head/gems/activesupport-4.2.5/lib/active_support/core_ext/object.rb:12:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/configuration.rb:2:in `require' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/configuration.rb:2:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/railtie.rb:2:in `require' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/railtie.rb:2:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/engine.rb:1:in `require' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/engine.rb:1:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/application.rb:7:in `require' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/application.rb:7:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails.rb:11:in `require' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails.rb:11:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/commands/server.rb:4:in `require' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/commands/server.rb:4:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:123:in `require' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:123:in `require_command!' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:73:in `server' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!' from /Users/John/.rvm/gems/ruby-head/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>' from /Users/John/Developer/Rails/blog/bin/rails:9:in `require' from /Users/John/Developer/Rails/blog/bin/rails:9:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/spring-1.6.1/lib/spring/client/rails.rb:28:in `load' from /Users/John/.rvm/gems/ruby-head/gems/spring-1.6.1/lib/spring/client/rails.rb:28:in `call' from /Users/John/.rvm/gems/ruby-head/gems/spring-1.6.1/lib/spring/client/command.rb:7:in `call' from /Users/John/.rvm/gems/ruby-head/gems/spring-1.6.1/lib/spring/client.rb:28:in `run' from /Users/John/.rvm/gems/ruby-head/gems/spring-1.6.1/bin/spring:51:in `<top (required)>' from /Users/John/.rvm/gems/ruby-head/gems/spring-1.6.1/lib/spring/binstub.rb:11:in `load' from /Users/John/.rvm/gems/ruby-head/gems/spring-1.6.1/lib/spring/binstub.rb:11:in `<top (required)>' from /Users/John/.rvm/rubies/ruby-head/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /Users/John/.rvm/rubies/ruby-head/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /Users/John/Developer/Rails/blog/bin/spring:13:in `<top (required)>' from bin/rails:3:in `load' from bin/rails:3:in `<main>' 

Gem list says that I have json (1.8.3, 1.8.2). I also tried reinstalling rails and updating my ruby version through rvm. Any idea what is wrong? I have tried looking around online but am a bit stuck especially as I have never used rails before and only a little ruby.

5
  • Are you using Windows or Linux? Commented Dec 26, 2015 at 20:57
  • it seems the native extensions for json are not compiled. Commented Dec 26, 2015 at 21:13
  • @RichPeck I'm using OS X Commented Dec 26, 2015 at 21:16
  • Does the same problem still occur when you run bundle exec rails server? Does bundle check run successfully? Is json mentioned in your Gemfile.lock? Commented Dec 26, 2015 at 22:33
  • @Raffael bundle exec rails server also fails. bundle check runs successfully returning The Gemfile's dependencies are satisfied. json is in Gemfile.lock several time e.g. cat gemfile.lock | grep json gives me json (~> 1.7, >= 1.7.7) multi_json (~> 1.2) json (1.8.3) multi_json (1.11.2) json (~> 1.4) json (~> 1.7, >= 1.7.7) json (>= 1.8.0) Commented Dec 27, 2015 at 0:39

5 Answers 5

20

Something's gotten weird/corrupted in your ruby environment. I'd blame rvm. Personally I am not a fan of rvm.

But you might try gem uninstall json, follow prompts to uninstall ALL versions. Then bundle install again. Then hopefully you'll be fixed up.

Sign up to request clarification or add additional context in comments.

5 Comments

I just tried this but no luck. The same as before Edit: spelling
Just noticed that I was having the issue with sqlite3 after. Did the same for that and debug_inspector et voila it works!
You can gem pristine --all to automatially uninstall and reinstall all installed gems in the current environment. It will take a while. Coincidentally the same thing that warning at the top of your output was recommending, although it was recommending it for a different reason, to make Spring work better (I don't use Spring myself), it was, I think, recommending it because it noticed you had installed gems with an earlier version of ruby than you are currently using, which is normally fine except for some compiled gems.
Even after using gem pristine --all I also had this error happen. In the end I had to just keep doing the gem uninstall followed by bundle install until it finally would work.
@jrochkind, gem pristine --all worked for me. Thank you!
4

Remove vendor and run bundle install could solve this problem. It worked for me.

1 Comment

That helped after brew had pulled in some new Ruby version.
2

I had a similar problem to what you described after I had taken a different ruby version into use (from 2.3.0 -> 2.3.3).

I found that running:

$ gem install bundler 

Then:

$ bundle install 

... worked a charm for me. This reinstalled all of the packages I needed in my Gemfile without any dependency issues.

Comments

2

You can just re-download all dependencies when doing bundle install and it should fix it.

This worked for me on Rails 6

bundle install --redownload 

Comments

0

It looks like a never version of json gem is already present and being picked up by rails. You could either remove the version manually:

gem uninstall json -v 1.8.2 

or, since you're using RVM already, create a gemset specific to this project.

3 Comments

You ought not to need to do either of these things, it should be quite possible to have multiple versions of the json gem installed, and your app should use the one specified in it's dependency requirements, because that's what bundler does. But I'm not sure what's going on either. But if I were you, I would not try to work around it with these suggestions, it is likely to just lead to more confusion later.
Since this is a gem with native extensions, I agree with uninstalling and reinstalling. Apparently the native extensions were compiled with 1.8.2 and 1.8.3 cannot use them.
Cannot uninstall json 1.8.2 because it is a default gem

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.