65

I`m in root of my application, and when I type

$ rails console

It looks like something is loading, but nothing happens.

And when I stop ^C I received this trace:

^C/home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/run.rb:54:in `gets': Interrupt
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/run.rb:54:in `verify_server_version'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/run.rb:25:in `call'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/rails.rb:23:in `call'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/jonatas/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/jonatas/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/jonatas/Code/Ruby/jonatasteixeira/bin/spring:16:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'

I have no idea whats going on..

Cœur
  • 37,241
  • 25
  • 195
  • 267
JonatasTeixeira
  • 1,474
  • 1
  • 18
  • 24

7 Answers7

233

I may be answering a bit late for this, but for the sake of the others who are looking for the answer... it's here

Basically, enter this command

spring stop

The issue , as far as I understand, is with the spring gem, specifically, it checks the server for versions, which doesn't tally up.

For my case, the problem started when when I add some new gems into the gemfile.

So once you stop spring and type in any other rails command, spring restart, and every thing should work again, at least until the same problem occurs, or the dev patched the issue.

On a Railsroad
  • 2,346
  • 1
  • 11
  • 2
  • this one work for me too, I was trying to run `rails runner`, and it just return immediately without output or run anything, and then I try `rails console`, same thing happen, but `rails s` work. and I try this `spring stop` then rails console work again! – NamNamNam Nov 02 '17 at 07:23
  • there is an answer below that suggests commenting out `spring`. That did not help. Even commeted out, I had to `spring stop`to get the console working. – Jerome Nov 14 '17 at 11:17
  • 2.5 years down the road, this answer helped me after a day of trawlling thru google. @on_a_railsroad. – ali Dec 11 '17 at 03:32
  • It's July 2018 and this answer is still useful! I'm on Ruby 5.0.7 and Spring 2.0.2. – bjacquet Jul 16 '18 at 14:15
  • Gosh this was driving me nuts. Thanks for the answer – vinibol12 Oct 30 '19 at 18:10
  • This answer just patched the issue, but I don't know how to avoid that it occurs again? Some one knows why happen this problem with spring. In my case occurs each time that I run `rails runner` or `rails console`. – Esteban CAES Sep 09 '21 at 18:20
11

I've not seen this before, but it looks like maybe spring is messed up in your setup for some reason? Try going into your Gemfile and look for the line that calls gem 'spring' and comment that out. Then run bundle install and try again.

This isn't a proper solution, but if it gets your rails console working again tonight then hopefully it will help you out until a proper solution is discovered.

bratsche
  • 2,666
  • 20
  • 23
8

Running spring stop did the trick for me.

4

For me spring gem was causing this issue running spring stop resolved this.

2

In my case, the same trouble is occured on my production environment.

If your environmet is also production, in the first place, you must not install spring on your production environment.

refer this https://github.com/rails/spring/issues/318 https://github.com/rails/spring/pull/337/files

It can be resolved by this command on your production

RAILS_ENV=production bundle install --clean --without development test

kazuwombat
  • 1,515
  • 1
  • 16
  • 19
2

I could run rails console again in Rails 5.2.1 with:

  • bundle clean --force
  • bundle install --without development test

Note: My RAILS_ENV variable is already set to production.

Is Ma
  • 913
  • 11
  • 14
1

I had the same problem in the production environment. The spring gem was not in the development group in the Gemfile. After I correct this all worked fine.

Matthias
  • 11
  • 1