Skip to content

Commit 3459158

Browse files
committed
Disable with DISABLE_SPRING_WATCHER_LISTEN env var
We have a project where some Engineers are running configurations that do not support `inotify`, which causes an error when this gem is loaded. We still want these Engineers to be able to use Spring in polling mode. We tried setting `require: false` in the `Gemfile` but [Spring loads the gem anyway](https://github.com/rails/spring/blob/a318a1837524ea6e39a7073af94e75131fcc95d1/lib/spring/commands.rb#L35-L46). This change introduces a new env var `DISABLE_SPRING_WATCHER_LISTEN` which, along the lines of `DISABLE_SPRING`, disables the functionality in this gem.
1 parent fee5ced commit 3459158

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ On larger projects this means spring will be more responsive, more accurate and
1414
Listen 2.7 and higher and 3.0 are supported.
1515
If you rely on Listen 1 you can use v1.0.0 of this gem.
1616

17+
## Environment variables
18+
19+
* `DISABLE_SPRING_WATCHER_LISTEN` - If set, this disables the loading of this gem. This can be useful for projects where
20+
some configurations do not support inotify (e.g. Docker on M1 Macs).
21+
1722
## Installation
1823

1924
Stop Spring if it's already running:

lib/spring/watcher/listen.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
return if ENV['DISABLE_SPRING_WATCHER_LISTEN']
2+
13
require "spring/watcher"
24
require "spring/watcher/abstract"
35

0 commit comments

Comments
 (0)