guard / listen

The Listen gem listens to file modifications and notifies you about the changes.
https://rubygems.org/gems/listen
MIT License
1.92k stars 246 forks source link

Support darwin20 / macOS Big Sur #478

Closed christiankn closed 3 years ago

christiankn commented 4 years ago

Listen doesn't identify macOS 10.16/11.0 as compatible with the Darwin-adapter because of version number change, and falls back to polling.

The Darwin-adapter checks _targetos for version compatibility by looking for versions starting with "1", capturing [10,19].

macOS Big Sur has a _targetos of "darwin20", failing to be captured by the regex and causing listen to fall back to polling.

#listen/adapter/darwin.rb
OS_REGEXP = /darwin(?<major_version>1\d+)/i
#(...)
version = RbConfig::CONFIG['target_os'][OS_REGEXP, :major_version]
return false unless version
return true if version.to_i >= 13 # darwin13 is OS X 10.9

Could be fixed by changing the regex, assuming there are no other reasons adapter should break on Big Sur.

OS_REGEXP = /darwin(?<major_version>(1|2)\d+)/i

Notes: This issue naturally causes high CPU-usage on Rails for developers upgrading to macOS Big Sur, when application is not properly configured to use Polling.

It seems to be working as expected with the above change, but I haven't tested it extensively.

ioquatix commented 4 years ago

This has been merged into master, can you please test it?

fearoffish commented 3 years ago

@ioquatix Looks good to me. Thanks.