Ruby on Rails console is hanging when loading

后端 未结 5 2009
梦如初夏
梦如初夏 2020-12-04 10:01

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

相关标签:
5条回答
  • 2020-12-04 10:19

    Restarting Spring should fix the hanging commands:

    $ 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.

    Spring will start automatically when you re-run your command.

    0 讨论(0)
  • 2020-12-04 10:20

    If $ bin/spring stop doesn't solve the issue, then check to make sure there isn't an orphaned Spring process still hanging around:

    $ 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:

    $ kill -9 16980 
    $ rails c
    
    0 讨论(0)
  • 2020-12-04 10:34

    When it is suspected that Spring is the cause of weirdness, try to run this command:

    spring stop && spring start
    
    0 讨论(0)
  • 2020-12-04 10:38

    Changing the following method in the lib/application.rb file of the spring gem (path can be shown with the gem info spring command) like this does the trick:

    def eager_preload
          with_pty do
            # we can't see stderr and there could be issues when it's overflown
            # see https://github.com/rails/spring/issues/396
            STDERR.reopen("/dev/null")
            preload
          end
    end
    

    see https://github.com/markiz/spring/commit/5f3ab734fc45d541aaaccb05b59cd95aa49fe8ef

    0 讨论(0)
  • 2020-12-04 10:44

    It's something wrong with the Spring gem version I guess.

    Go to your Gemfile and comment gem 'spring'. Then run bundle install and try again.

    # gem 'spring'
    

    And then:

    bundle install
    

    If your work depends on the gem, try update the gems by:

    bundle update
    
    0 讨论(0)
提交回复
热议问题