加载时 Ruby on Rails 控制台挂起
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25027284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ruby on Rails console is hanging when loading
提问by theog
For whatever reason, the Ruby on Rails console refuses to start; it just hangs. I haven't made any changes to my code, and other projects using the same version of Ruby and Ruby on Rails have no issue. When I finally Ctrl+ CI get this stack trace, which points to Spring.
无论出于何种原因,Ruby on Rails 控制台都拒绝启动;它只是挂起。我没有对我的代码进行任何更改,使用相同版本的 Ruby 和 Ruby on Rails 的其他项目没有问题。当我最终Ctrl+C我得到这个指向 Spring 的堆栈跟踪时。
I can't explain why this is happening from one moment to the next, where it was working fine. I have cleared out all the gems through RVM and reinstalled all through bundle command, but still no luck. Any ideas would be appreciated.
我无法解释为什么这会从一个时刻发生到下一个时刻,它运行良好。我已经通过 RVM 清除了所有的 gem,并通过 bundle 命令重新安装了所有的东西,但仍然没有运气。任何想法,将不胜感激。
Also the Ruby on Rails server has no issue so as far as I can tell. The issue is project related, however no code has changed, and it's only the Ruby on Rails console that has the issue.
据我所知,Ruby on Rails 服务器也没有问题。该问题与项目有关,但没有更改任何代码,只有 Ruby on Rails 控制台存在问题。
Ruby 2.1.2
Rails 4.1.4
红宝石 2.1.2
导轨 4.1.4
user_a@ubuntu:~/work/app_a$ rails console
^C/home/user_a/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/run.rb:54:in `gets': Interrupt
from /home/user_a/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/run.rb:54:in `verify_server_version'
from /home/user_a/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/run.rb:25:in `call'
from /home/user_a/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /home/user_a/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/rails.rb:23:in `call'
from /home/user_a/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /home/user_a/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
from /home/user_a/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
from /home/user_a/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
from /home/user_a/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/user_a/work/app_a/bin/spring:16:in `require'
from /home/user_a/work/app_a/bin/spring:16:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
user_a@ubuntu:~/work/app_a$
回答by cee-dub
Restarting Spring should fix the hanging commands:
重新启动 Spring 应该修复挂起的命令:
$ bin/spring stop
I experienced hanging commands (rake, bin/rails, etc.) after deleting and recreating a new Ruby on Rails application. Google wasn't that helpful. I hope this is.
在删除并重新创建新的 Ruby on Rails 应用程序后,我遇到了挂起命令(rake、bin/rails 等)。谷歌没有那么有帮助。我希望是这样。
Spring will start automatically when you re-run your command.
当您重新运行命令时,Spring 将自动启动。
回答by Eki Eqbal
It's something wrong with the Spring gem version I guess.
我猜是 Spring gem 版本有问题。
Go to your Gemfile and comment gem 'spring'. Then run bundle installand try again.
转到您的 Gemfile 并评论 gem 'spring'。然后运行bundle install并重试。
# gem 'spring'
And then:
进而:
bundle install
If your work depends on the gem, try update the gems by:
如果您的工作依赖于 gem,请尝试通过以下方式更新 gem:
bundle update
回答by littleforest
If $ bin/spring stopdoesn't solve the issue, then check to make sure there isn't an orphaned Spring process still hanging around:
如果$ bin/spring stop没有解决问题,请检查以确保没有孤立的 Spring 进程仍然存在:
$ ps aux | grep -i spring
If you see something like
如果你看到类似的东西
user 7163 0.0 0.0 110356 2165 pts/3 S+ 19:40 0:00 grep --color=auto -i spring
user 16980 0.0 0.4 398826 17580 ? Sl Aug31 0:00 spring server | current | started 277 hours ago
then kill the errant spring process and try to start the console again:
然后杀死错误的 spring 进程并尝试再次启动控制台:
$ kill -9 16980
$ rails c
回答by Yurii Halapup
When it is suspected that Spring is the cause of weirdness, try to run this command:
当怀疑是Spring引起的怪异时,尝试运行这个命令:
spring stop && spring start

