Skip to content

The listen gem breaks my laptop #26158

@benaubin

Description

@benaubin

Steps to reproduce

  1. Create a new rails app
  2. Run it on a Mac with a bad processor

Expected behavior

My laptop should work fine - processes should stay under the 700-something limit that Apple set.

Actual behavior

When running my Rails app on a Macbook Air with 1.8 ghz of cpu (I know... getting a new computer when they release the new Pro's), I have been getting a "System ran out of resources, can't fork any processes" error in all of my applications (or, they just quietly failed). Finally, I opened Activity Monitor and was able to find more then 500 fsevent_watch processes running (my computer has a maximum of 700 processes total). Doing a Google Search, I stumbled upon the [rb-fsevent gem]. Looking at my Gemfile.lock, I was able to track it down to the listen gem.

I'm unable to tell if it is an issue with the listen gem itself, or @fnx's implementation in Rails (see #22254), but it seems like it's more likely the implementation is broken.

Suggested Fix

I'm unable to tell if it is an issue with the listen gem itself, or @fnx's implementation in Rails (see #22254), but it seems like it's more likely the implementation is broken.

I would make sure that the listen gem is opt-in, especially on systems with low process limits (IIRC, there's a command that allows you to check this).

Temporary Workaround

If your computer is currently showing a "System ran out of resources, can't fork any processes" error, reboot it (logging in and out might work, but I haven't tested that). You probably won't be able to save most of your work (if your software forks a process in order to save).

To remove the gem for a more permanent fix

  1. Remove the listen and spring-watcher-listen gems.
  2. In your environments/development.rb file, comment out this line:
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker

System configuration

Rails version:
Rails 5.0.0
Ruby version:
ruby 2.3.0p0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions