Ruby on Rails incompatible library

23,094

Solution 1

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.

Solution 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.

Solution 3

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

Share:
23,094
John P
Author by

John P

Updated on September 16, 2021

Comments

  • John P
    John P over 2 years

    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.

  • jrochkind
    jrochkind over 8 years
    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.
  • Raffael
    Raffael over 8 years
    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.
  • John P
    John P over 8 years
    I just tried this but no luck. The same as before Edit: spelling
  • John P
    John P over 8 years
    Cannot uninstall json 1.8.2 because it is a default gem
  • John P
    John P over 8 years
    Just noticed that I was having the issue with sqlite3 after. Did the same for that and debug_inspector et voila it works!
  • jrochkind
    jrochkind over 8 years
    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.
  • Tim Holt
    Tim Holt about 8 years
    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.
  • Christopher Warrington
    Christopher Warrington over 6 years
    @jrochkind, gem pristine --all worked for me. Thank you!
  • Robert
    Robert over 2 years
    That helped after brew had pulled in some new Ruby version.