John P
John P

Reputation: 625

Ruby on Rails incompatible library

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.

Upvotes: 12

Views: 30651

Answers (5)

Coding Enthusiast
Coding Enthusiast

Reputation: 3933

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

Upvotes: 2

giapnh
giapnh

Reputation: 3258

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

Upvotes: 4

Lance Fono
Lance Fono

Reputation: 96

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.

Upvotes: 2

jrochkind
jrochkind

Reputation: 23317

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.

Upvotes: 21

sqbell
sqbell

Reputation: 121

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.

Upvotes: 0

Related Questions