Je viens tout juste de commencer à regarder Ruby on Rails et je ne parviens pas à faire fonctionner un serveur. J'utilise Ruby 2.3.0 et Rails 4.2.5 et après avoir créé un nouveau projet ferroviaire, j'essaie d'exécuter bin/Rails server
mais j'obtiens le message d'erreur suivant:
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>'
La liste des gemmes indique que j'ai json (1.8.3, 1.8.2)
. J'ai également essayé de réinstaller Rails et de mettre à jour ma version de Ruby via rvm. Une idée de ce qui ne va pas? J'ai essayé de regarder en ligne, mais je suis un peu coincé, surtout que je n'ai jamais utilisé Rails auparavant et que je n'ai qu'un peu Ruby.
Quelque chose est devenu bizarre/corrompu dans votre environnement Ruby. Je blâmerais RVM. Personnellement, je ne suis pas fan de RVM.
Mais vous pouvez essayer gem uninstall json
, suivez les instructions pour désinstaller TOUTES les versions. Puis bundle install
à nouveau. Alors j'espère que vous serez réparés.
J'ai eu un problème similaire à ce que vous avez décrit après avoir utilisé une version différente de Ruby (de 2.3.0 -> 2.3.3).
J'ai trouvé ça courir:
$ gem install bundler
Ensuite:
$ bundle install
... travaillé un charme pour moi. Cela a réinstallé tous les paquets dont j'avais besoin dans mon Gemfile sans aucun problème de dépendance.
Il semble qu'une version jamais de json
gem soit déjà présente et capturée par Rails. Vous pouvez soit supprimer la version manuellement:
gem uninstall json -v 1.8.2
ou, puisque vous utilisez déjà RVM, créez un gemset spécifique à ce projet.