rails generate命令无反应的解决办法

  • A+
所属分类:ruby 技巧

rails generate命令无反应的解决办法

在使用如下命令的时候等待许久无反应。

rails generate scaffold Product title:string description:text image_url:string price:decimal

ctrl+c后出现如下报错

^C/home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/run.rb:117:in `gets': Interrupt
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/run.rb:117:in `verify_server_version'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/run.rb:62:in `run'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/run.rb:42:in `warm_run'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/run.rb:35:in `call'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:24:in `call'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
        from /home/cailizhong/.rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
        from /www/web/myRailsApp/depot/bin/spring:15:in `<top (required)>'
        from bin/rails:3:in `load'
        from bin/rails:3:in `<main>'

解决办法:
执行spring stop命令即可。然后再重新执行你的命令。

参考:https://stackoverflow.com/questions/45312341/rails-hanging-when-trying-to-generate-controller

百分购

发表评论

您必须才能发表评论!