Rails console using 100% CPU in dev (fix)

If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issue - at least that’s what worked for me. Here’s my old and new (old versions are commented out):

# group :development do
#   # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
#   gem 'web-console', '>= 3.3.0'
#   gem 'listen', '>= 3.0.5', '< 3.2'
#   # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
#   gem 'spring'
#   gem 'spring-watcher-listen', '~> 2.0.0'
# end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 4.1.0'
  # Display performance information such as SQL time and flame graphs for each request in your browser.
  # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
  gem 'rack-mini-profiler', '~> 2.0'
  gem 'listen', '~> 3.3'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

# group :test do
#   # Adds support for Capybara system testing and selenium driver
#   gem 'capybara', '>= 2.15'
#   gem 'selenium-webdriver'
#   # Easy installation and use of web drivers to run system tests with browsers
#   gem 'webdrivers'
# end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 3.26'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

Hope this saves someone a few hours of faffing around trying to troubleshoot the issue! :upside_down_face:

1 Like

Corresponding tweet for this thread:

https://twitter.com/dev_talk/status/1356851929104678913

Share link for this tweet.


Related portals:

It was probably listen. listen 3.3.0 fixed a lot of threading and process problems.

1 Like

Glad they sorted it because it was driving me crazy! :joy:

Stopping the server wasn’t enough either, you needed to quit terminal completely :man_facepalming:

I’ve had some trouble with spring just sitting there as well. spring is used to preload the app, so you can tear down and start up a server or console snappy.

1 Like