listen 3.0.2 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 31cbd0621bbc7503ca3a3239d6af0a796944ec97
4
- data.tar.gz: a8c58b2604188b167c3f8f9ae31d34aa3ffd593a
2
+ SHA256:
3
+ metadata.gz: c0fcb6d45a23b63f02ec16878ffe9800bc52a32f93fbc5b7e1f03ed647398849
4
+ data.tar.gz: 3d05dea88713a500aca3fb2d8612e7a9a9d6125a9c2573f497fe46482386ad84
5
5
  SHA512:
6
- metadata.gz: f08ecd2918a8ae98493be6ffdf2f8062c2cedc835b780a59d55f0225d4a062b92712e1c7eb756879efd9fe29917e0f7d667e5a36a0abc4c8433bf7ee02c2565f
7
- data.tar.gz: fb4b454fe90e5eb549420dbe3745d12a4edeea9e3df5613e39817d9dfad7c835b624b60644b972c9c3ab4e2e59fec83cc17af807ac667952718b1873dd5fea31
6
+ metadata.gz: 81fb2d73327b8d75aff7156f65fc6949d400aef6ef9e6455ee37e0a9d389adb4b010df0565f160001d90da0496887c71bff8f25076c8fa7c37ddb9ce05511fc1
7
+ data.tar.gz: 6e1f35517e6557e46e02e3b985792b0a8aa661470117f648d209917a9eac6987282c57fc30ad6857f702305cf695c16081535fc11f8a434974f068c0bb6aeafe
data/CONTRIBUTING.md CHANGED
@@ -4,7 +4,7 @@ Contribute to Listen
4
4
  File an issue
5
5
  -------------
6
6
 
7
- If you haven't already, first see [TROUBLESHOOTING](https://github.com/guard/listen/wiki/Troubleshooting) for known issues, solutions and workarounds.
7
+ If you haven't already, first see [TROUBLESHOOTING](https://github.com/guard/listen/blob/master/README.md#Issues-and-Troubleshooting) for known issues, solutions and workarounds.
8
8
 
9
9
  You can report bugs and feature requests to [GitHub Issues](https://github.com/guard/listen/issues).
10
10
 
@@ -16,7 +16,7 @@ Try to figure out where the issue belongs to: Is it an issue with Listen itself
16
16
 
17
17
  **It's most likely that your bug gets resolved faster if you provide as much information as possible!**
18
18
 
19
- The MOST useful information is debugging output from Listen (`LISTEN_GEM_DEBUGGING=1`) - see [TROUBLESHOOTING](https://github.com/guard/listen/wiki/Troubleshooting) for details.
19
+ The MOST useful information is debugging output from Listen (`LISTEN_GEM_DEBUGGING=1`) - see [TROUBLESHOOTING](https://github.com/guard/listen/blob/master/README.md#Issues-and-Troubleshooting) for details.
20
20
 
21
21
 
22
22
  Development
@@ -31,8 +31,15 @@ Pull requests are very welcome! Please try to follow these simple rules if appli
31
31
  * Make sure your patches are well tested. All specs run with `rake spec` must pass.
32
32
  * Update the [Yard](http://yardoc.org/) documentation.
33
33
  * Update the [README](https://github.com/guard/listen/blob/master/README.md).
34
- * Update the [CHANGELOG](https://github.com/guard/listen/blob/master/CHANGELOG.md) for noteworthy changes.
35
34
  * Please **do not change** the version number.
36
35
 
36
+ The title of your PR will automatically be included in the release notes for the next version of the gem. A maintainer can add one of the following GitHub labels to the PR to automatically categorize it when the release notes are generated:
37
+
38
+ - ⚠️ Breaking
39
+ - ✨ Feature
40
+ - 🐛 Bug Fix
41
+ - 📚 Docs
42
+ - 🏠 Housekeeping
43
+
37
44
  For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
38
45
  `#guard` (irc.freenode.net).
data/README.md CHANGED
@@ -1,23 +1,11 @@
1
- ### :warning: Listen is [looking for new maintainers](https://groups.google.com/forum/#!topic/guard-dev/2Td0QTvTIsE). Please [contact me](mailto:thibaud@thibaud.gg) if you're interested.
2
-
3
1
  # Listen
4
2
 
5
- [![Gem Version](https://badge.fury.io/rb/listen.png)](http://badge.fury.io/rb/listen) [![Build Status](https://travis-ci.org/guard/listen.png)](https://travis-ci.org/guard/listen) [![Dependency Status](https://gemnasium.com/guard/listen.png)](https://gemnasium.com/guard/listen) [![Code Climate](https://codeclimate.com/github/guard/listen.png)](https://codeclimate.com/github/guard/listen) [![Coverage Status](https://coveralls.io/repos/guard/listen/badge.png?branch=master)](https://coveralls.io/r/guard/listen)
6
-
7
- The Listen gem listens to file modifications and notifies you about the changes.
8
-
9
- ## Known issues / Quickfixes / Workarounds
10
-
11
- *NOTE: TCP functionality has been removed from Listen 3.x - please use Listen
12
- 2.x until alternative server and client gems are created/released for 3.x.*
3
+ The `listen` gem listens to file modifications and notifies you about the changes.
13
4
 
14
- *NOTE: Ruby 1.9.3 is no longer maintained (and may not work with Listen) - it's best to upgrade to Ruby 2.2.2*
15
-
16
- For other issues, just head over here: https://github.com/guard/listen/wiki/Quickfixes,-known-issues-and-workarounds
17
-
18
- ## Tips and Techniques
19
-
20
- Make sure you know these few basic tricks: https://github.com/guard/listen/wiki/Tips-and-Techniques
5
+ [![Development Status](https://github.com/guard/listen/workflows/Development/badge.svg)](https://github.com/guard/listen/actions?workflow=Development)
6
+ [![Gem Version](https://badge.fury.io/rb/listen.svg)](http://badge.fury.io/rb/listen)
7
+ [![Code Climate](https://codeclimate.com/github/guard/listen.svg)](https://codeclimate.com/github/guard/listen)
8
+ [![Coverage Status](https://coveralls.io/repos/guard/listen/badge.svg?branch=master)](https://coveralls.io/r/guard/listen)
21
9
 
22
10
  ## Features
23
11
 
@@ -26,73 +14,116 @@ Make sure you know these few basic tricks: https://github.com/guard/listen/wiki/
26
14
  * You can watch multiple directories.
27
15
  * Regexp-patterns for ignoring paths for more accuracy and speed
28
16
  * Increased change detection accuracy on OS X HFS and VFAT volumes.
29
- * Tested on MRI Ruby environments (2.0+ only) via [Travis CI](https://travis-ci.org/guard/listen),
30
-
31
- NOTE: TCP functionality has been moved to a separate gem (listen-server and listen-client)
32
-
33
- NOTES:
34
- - Some filesystems won't work without polling (VM/Vagrant Shared folders, NFS, Samba, sshfs, etc.)
35
- - Specs suite on JRuby and Rubinius aren't reliable on Travis CI, but should work.
36
- - Windows and \*BSD adapter aren't continuously and automaticaly tested.
17
+ * Continuous Integration: tested on selected Ruby environments via [Github Workflows](https:///github.com/guard/listen/master/.github/workflows).
37
18
 
19
+ ## Issues / limitations
38
20
 
39
- ## Pending features / issues
21
+ * Limited support for symlinked directories ([#279](https://github.com/guard/listen/issues/279)):
22
+ * Symlinks are always followed ([#25](https://github.com/guard/listen/issues/25)).
23
+ * Symlinked directories pointing within a watched directory are not supported ([#273](https://github.com/guard/listen/pull/273).
24
+ * No directory/adapter-specific configuration options.
25
+ * Support for plugins planned for future.
26
+ * TCP functionality was removed in `listen` [3.0.0](https://github.com/guard/listen/releases/tag/v3.0.0) ([#319](https://github.com/guard/listen/issues/319), [#218](https://github.com/guard/listen/issues/218)). There are plans to extract this feature to separate gems ([#258](https://github.com/guard/listen/issues/258)), until this is finished, you can use by locking the `listen` gem to version `'~> 2.10'`.
27
+ * Some filesystems won't work without polling (VM/Vagrant Shared folders, NFS, Samba, sshfs, etc.).
28
+ * Windows and \*BSD adapter aren't continuously and automatically tested.
29
+ * OSX adapter has some performance limitations ([#342](https://github.com/guard/listen/issues/342)).
30
+ * Listeners do not notify across forked processes, if you wish for multiple processes to receive change notifications you must [listen inside of each process](https://github.com/guard/listen/issues/398#issuecomment-223957952).
40
31
 
41
- * symlinked directories aren't fully transparent yet: https://github.com/guard/listen/issues/279
42
- * Directory/adapter specific configuration options
43
- * Support for plugins
44
-
45
- Pull request or help is very welcome for these.
32
+ Pull requests or help is very welcome for these.
46
33
 
47
34
  ## Install
48
35
 
49
- The simplest way to install Listen is to use [Bundler](http://bundler.io).
36
+ The simplest way to install `listen` is to use [Bundler](http://bundler.io).
37
+
38
+ ```ruby
39
+ gem 'listen'
40
+ ```
50
41
 
42
+ ## Complete Example
43
+ Here is a complete example of using the `listen` gem:
51
44
  ```ruby
52
- gem 'listen', '~> 3.0' # NOTE: for TCP functionality, use '~> 2.10' for now
45
+ require 'listen'
46
+
47
+ listener = Listen.to('/srv/app') do |modified, added, removed|
48
+ puts(modified: modified, added: added, removed: removed)
49
+ end
50
+ listener.start
51
+ sleep
52
+ ```
53
+ Running the above in the background, you can see the callback block being called in response to each command:
53
54
  ```
55
+ $ cd /srv/app
56
+ $ touch a.txt
57
+ {:modified=>[], :added=>["/srv/app/a.txt"], :removed=>[]}
58
+
59
+ $ echo more >> a.txt
60
+ {:modified=>["/srv/app/a.txt"], :added=>[], :removed=>[]}
54
61
 
62
+ $ mv a.txt b.txt
63
+ {:modified=>[], :added=>["/srv/app/b.txt"], :removed=>["/srv/app/a.txt"]}
64
+
65
+ $ vi b.txt
66
+ # add a line to this new file and press ZZ to save and exit
67
+ {:modified=>["/srv/app/b.txt"], :added=>[], :removed=>[]}
68
+
69
+ $ vi c.txt
70
+ # add a line and press ZZ to save and exit
71
+ {:modified=>[], :added=>["/srv/app/c.txt"], :removed=>[]}
72
+
73
+ $ rm b.txt c.txt
74
+ {:modified=>[], :added=>[], :removed=>["/srv/app/b.txt", "/srv/app/c.txt"]}
75
+ ```
55
76
 
56
77
  ## Usage
57
78
 
58
- Call `Listen.to` with either a single directory or multiple directories, then define the "changes" callback in a block.
79
+ Call `Listen.to` with one or more directories and the "changes" callback passed as a block.
59
80
 
60
81
  ``` ruby
61
82
  listener = Listen.to('dir/to/listen', 'dir/to/listen2') do |modified, added, removed|
62
- puts "modified absolute path: #{modified}"
63
- puts "added absolute path: #{added}"
64
- puts "removed absolute path: #{removed}"
83
+ puts "modified absolute path array: #{modified}"
84
+ puts "added absolute path array: #{added}"
85
+ puts "removed absolute path array: #{removed}"
65
86
  end
66
- listener.start # not blocking
87
+ listener.start # starts a listener thread--does not block
88
+
89
+ # do whatever you want here...just don't exit the process :)
90
+
67
91
  sleep
68
92
  ```
93
+ ## Changes Callback
69
94
 
70
- ### Pause / unpause / stop
95
+ Changes to the listened-to directories are reported by the listener thread in a callback.
96
+ The callback receives **three** array parameters: `modified`, `added` and `removed`, in that order.
97
+ Each of these three is always an array with 0 or more entries.
98
+ Each array entry is an absolute path.
71
99
 
72
- Listeners can also be easily paused/unpaused:
100
+ ### Pause / start / stop
101
+
102
+ Listeners can also be easily paused and later un-paused with start:
73
103
 
74
104
  ``` ruby
75
- listener = Listen.to('dir/path/to/listen') { |modified, added, removed| # ... }
105
+ listener = Listen.to('dir/path/to/listen') { |modified, added, removed| puts 'handle changes here...' }
76
106
 
77
107
  listener.start
78
- listener.paused? # => false
108
+ listener.paused? # => false
79
109
  listener.processing? # => true
80
110
 
81
- listener.pause # stops processing changes (but keeps on collecting them)
82
- listener.paused? # => true
111
+ listener.pause # stops processing changes (but keeps on collecting them)
112
+ listener.paused? # => true
83
113
  listener.processing? # => false
84
114
 
85
- listener.unpause # resumes processing changes ("start" would do the same)
86
- listener.stop # stop both listening to changes and processing them
115
+ listener.start # resumes processing changes
116
+ listener.stop # stop both listening to changes and processing them
87
117
  ```
88
118
 
89
- Note: While paused, Listen keeps on collecting changes in the background - to clear them, call "stop"
119
+ Note: While paused, `listen` keeps on collecting changes in the background - to clear them, call `stop`.
90
120
 
91
- Note: You should keep track of all started listeners and stop them properly on finish.
121
+ Note: You should keep track of all started listeners and `stop` them properly on finish.
92
122
 
93
123
  ### Ignore / ignore!
94
124
 
95
- Listen ignores some directories and extensions by default (See DEFAULT_IGNORED_DIRECTORIES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer), you can add ignoring patterns with the `ignore` option/method or overwrite default with `ignore!` option/method.
125
+ `Listen` ignores some directories and extensions by default (See DEFAULT_IGNORED_FILES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer).
126
+ You can add ignoring patterns with the `ignore` option/method or overwrite default with `ignore!` option/method.
96
127
 
97
128
  ``` ruby
98
129
  listener = Listen.to('dir/path/to/listen', ignore: /\.txt/) { |modified, added, removed| # ... }
@@ -102,13 +133,13 @@ listener.ignore /\.rb/ # ignore rb extension in addition of pkg.
102
133
  sleep
103
134
  ```
104
135
 
105
- Note: Ignoring regexp patterns are evaluated against relative paths.
136
+ Note: `:ignore` regexp patterns are evaluated against relative paths.
106
137
 
107
- Note: ignoring paths does not improve performance - except when Polling
138
+ Note: Ignoring paths does not improve performance, except when Polling ([#274](https://github.com/guard/listen/issues/274)).
108
139
 
109
140
  ### Only
110
141
 
111
- Listen catches all files (less the ignored once) by default, if you want to only listen to a specific type of file (ie: just rb extension) you should use the `only` option/method.
142
+ `Listen` watches all files (less the ignored ones) by default. If you want to only listen to a specific type of file (i.e., just `.rb` extension), you should use the `only` option/method.
112
143
 
113
144
  ``` ruby
114
145
  listener = Listen.to('dir/path/to/listen', only: /\.rb$/) { |modified, added, removed| # ... }
@@ -117,37 +148,8 @@ listener.only /_spec\.rb$/ # overwrite all existing only patterns.
117
148
  sleep
118
149
  ```
119
150
 
120
- Note: ':only' regexp patterns are evaluated only against relative **file** paths.
121
-
122
-
123
- ## Changes callback
124
-
125
- Changes to the listened-to directories gets reported back to the user in a callback.
126
- The registered callback gets invoked, when there are changes, with **three** parameters:
127
- `modified`, `added` and `removed` paths, in that particular order.
128
- Paths are always returned in their absolute form.
151
+ Note: `:only` regexp patterns are evaluated only against relative **file** paths.
129
152
 
130
- Example:
131
-
132
- ```ruby
133
- listener = Listen.to('path/to/app') do |modified, added, removed|
134
- # This block will be called when there are changes.
135
- end
136
- listener.start
137
- sleep
138
- ```
139
-
140
- or ...
141
-
142
- ```ruby
143
- # Create a callback
144
- callback = Proc.new do |modified, added, removed|
145
- # This proc will be called when there are changes.
146
- end
147
- listener = Listen.to('dir', &callback)
148
- listener.start
149
- sleep
150
- ```
151
153
 
152
154
  ## Options
153
155
 
@@ -155,7 +157,7 @@ All the following options can be set through the `Listen.to` after the directory
155
157
 
156
158
  ```ruby
157
159
  ignore: [%r{/foo/bar}, /\.pid$/, /\.coffee$/] # Ignore a list of paths
158
- # default: See DEFAULT_IGNORED_DIRECTORIES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer
160
+ # default: See DEFAULT_IGNORED_FILES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer
159
161
 
160
162
  ignore!: %r{/foo/bar} # Same as ignore options, but overwrite default ignored paths.
161
163
 
@@ -174,19 +176,46 @@ force_polling: true # Force the use of the polling a
174
176
  relative: false # Whether changes should be relative to current dir or not
175
177
  # default: false
176
178
 
177
- debug: true # Enable Listen logger
178
- # default: false
179
-
180
179
  polling_fallback_message: 'custom message' # Set a custom polling fallback message (or disable it with false)
181
180
  # default: "Listen will be polling for changes. Learn more at https://github.com/guard/listen#listen-adapters."
182
181
  ```
183
182
 
184
- Also, setting the environment variable `LISTEN_GEM_DEBUGGING=1` does the same as `debug: true` above.
183
+ ## Logging and Debugging
185
184
 
185
+ `Listen` logs its activity to `Listen.logger`.
186
+ This is the primary method of debugging.
186
187
 
187
- ## Listen adapters
188
+ ### Custom Logger
189
+ You can call `Listen.logger =` to set a custom `listen` logger for the process. For example:
190
+ ```
191
+ Listen.logger = Rails.logger
192
+ ```
193
+
194
+ ### Default Logger
195
+ If no custom logger is set, a default `listen` logger which logs to to `STDERR` will be created and assigned to `Listen.logger`.
196
+
197
+ The default logger defaults to the `error` logging level (severity).
198
+ You can override the logging level by setting the environment variable `LISTEN_GEM_DEBUGGING=<level>`.
199
+ For `<level>`, all standard `::Logger` levels are supported, with any mix of upper-/lower-case:
200
+ ```
201
+ export LISTEN_GEM_DEBUGGING=debug # or 2 [deprecated]
202
+ export LISTEN_GEM_DEBUGGING=info # or 1 or true or yes [deprecated]
203
+ export LISTEN_GEM_DEBUGGING=warn
204
+ export LISTEN_GEM_DEBUGGING=fatal
205
+ export LISTEN_GEM_DEBUGGING=error
206
+ ```
207
+ The default of `error` will be used if an unsupported value is set.
188
208
 
189
- The Listen gem has a set of adapters to notify it when there are changes.
209
+ Note: The alternate values `1`, `2`, `true` and `yes` shown above are deprecated and will be removed from `listen` v4.0.
210
+
211
+ ### Disabling Logging
212
+ If you want to disable `listen` logging, set
213
+ ```
214
+ Listen.logger = ::Logger.new('/dev/null')
215
+ ```
216
+ ## Listen Adapters
217
+
218
+ The `Listen` gem has a set of adapters to notify it when there are changes.
190
219
 
191
220
  There are 4 OS-specific adapters to support Darwin, Linux, \*BSD and Windows.
192
221
  These adapters are fast as they use some system-calls to implement the notifying function.
@@ -194,25 +223,25 @@ These adapters are fast as they use some system-calls to implement the notifying
194
223
  There is also a polling adapter - although it's much slower than other adapters,
195
224
  it works on every platform/system and scenario (including network filesystems such as VM shared folders).
196
225
 
197
- The Darwin and Linux adapters are dependencies of the Listen gem so they work out of the box. For other adapters a specific gem will have to be added to your Gemfile, please read below.
226
+ The Darwin and Linux adapters are dependencies of the `listen` gem so they work out of the box. For other adapters a specific gem will have to be added to your Gemfile, please read below.
198
227
 
199
- The Listen gem will choose the best adapter automatically, if present. If you
228
+ The `listen` gem will choose the best adapter automatically, if present. If you
200
229
  want to force the use of the polling adapter, use the `:force_polling` option
201
230
  while initializing the listener.
202
231
 
203
232
  ### On Windows
204
233
 
205
- If your are on Windows, it's recommended to use the [`wdm`](https://github.com/Maher4Ever/wdm) adapter instead of polling.
234
+ If you are on Windows, it's recommended to use the [`wdm`](https://github.com/Maher4Ever/wdm) adapter instead of polling.
206
235
 
207
236
  Please add the following to your Gemfile:
208
237
 
209
238
  ```ruby
210
- gem 'wdm', '>= 0.1.0' if Gem.win_platform?
239
+ gem 'wdm', '>= 0.1.0', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
211
240
  ```
212
241
 
213
242
  ### On \*BSD
214
243
 
215
- If your are on \*BSD you can try to use the [`rb-kqueue`](https://github.com/mat813/rb-kqueue) adapter instead of polling.
244
+ If you are on \*BSD you can try to use the [`rb-kqueue`](https://github.com/mat813/rb-kqueue) adapter instead of polling.
216
245
 
217
246
  Please add the following to your Gemfile:
218
247
 
@@ -226,34 +255,144 @@ end
226
255
 
227
256
  ### Getting the [polling fallback message](#options)?
228
257
 
229
- Please visit the [installation section of the Listen WIKI](https://github.com/guard/listen/wiki#installation) for more information and options for potential fixes.
258
+ If you see:
259
+ ```
260
+ Listen will be polling for changes.
261
+ ```
262
+
263
+ This means the Listen gem can’t find an optimized adapter. Typically this is caused by:
264
+
265
+ - You’re on Windows and WDM gem isn’t installed.
266
+ - You’re running the app without Bundler or RubyGems.
267
+ - Using Sass which includes an ancient (the “dinosaur” type of ancient) version of the Listen gem.
268
+
269
+ Possible solutions:
270
+
271
+ 1. Suppress the message by using the :force_polling option. Or, you could just ignore the message since it’s harmless.
272
+ 2. Windows users: Install the WDM gem.
273
+ 3. Upgrade Ruby (use RubyInstaller for Windows or RVM/rbenv for Mac) and RubyGems.
274
+ 3. Run your apps using Bundler.
275
+ 4. Sass users: Install the latest version of Listen and try again.
276
+
277
+ #### Simplified Bundler and Sass example
278
+ Create a Gemfile with these lines:
279
+ ```
280
+ source 'https://rubygems.org'
281
+ gem 'listen'
282
+ gem 'sass'
283
+ ```
284
+ Next, use Bundler to update gems:
285
+ ```
286
+ $ bundle update
287
+ $ bundle exec sass --watch # ... or whatever app is using Listen.
288
+ ```
289
+
290
+ ### Increasing the amount of inotify watchers
291
+
292
+ If you are running Debian, RedHat, or another similar Linux distribution, run the following in a terminal:
293
+ ```
294
+ $ sudo sh -c "echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf"
295
+ $ sudo sysctl -p
296
+ ```
297
+ If you are running ArchLinux, search the `/etc/sysctl.d/` directory for config files with the setting:
298
+ ```
299
+ $ grep -H -s "fs.inotify.max_user_watches" /etc/sysctl.d/*
300
+ /etc/sysctl.d/40-max_user_watches.conf:fs.inotify.max_user_watches=100000
301
+ ```
302
+ Then change the setting in the file you found above to a higher value (see [here](https://www.archlinux.org/news/deprecation-of-etcsysctlconf/) for why):
303
+ ```
304
+ $ sudo sh -c "echo fs.inotify.max_user_watches=524288 > /etc/sysctl.d/40-max-user-watches.conf"
305
+ $ sudo sysctl --system
306
+ ```
307
+
308
+ #### The technical details
309
+ Listen uses `inotify` by default on Linux to monitor directories for changes.
310
+ It's not uncommon to encounter a system limit on the number of files you can monitor.
311
+ For example, Ubuntu Lucid's (64bit) `inotify` limit is set to 8192.
312
+
313
+ You can get your current inotify file watch limit by executing:
314
+ ```
315
+ $ cat /proc/sys/fs/inotify/max_user_watches
316
+ ```
317
+ When this limit is not enough to monitor all files inside a directory, the limit must be increased for Listen to work properly.
318
+
319
+ You can set a new limit temporarily with:
320
+ ```
321
+ $ sudo sysctl fs.inotify.max_user_watches=524288
322
+ $ sudo sysctl -p
323
+ ```
324
+ If you like to make your limit permanent, use:
325
+ ```
326
+ $ sudo sh -c "echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf"
327
+ $ sudo sysctl -p
328
+ ```
329
+ You may also need to pay attention to the values of `max_queued_events` and `max_user_instances` if Listen keeps on complaining.
230
330
 
231
- ### Issues and troubleshooting
331
+ #### More info
332
+ Man page for [inotify(7)](https://linux.die.net/man/7/inotify).
333
+ Blog post: [limit of inotify](https://blog.sorah.jp/2012/01/24/inotify-limitation).
232
334
 
233
- *NOTE: without providing the output after setting the `LISTEN_GEM_DEBUGGING=1` environment variable, it can be almost impossible to guess why listen is not working as expected.*
335
+ ### Issues and Troubleshooting
234
336
 
235
- See [TROUBLESHOOTING](https://github.com/guard/listen/wiki/Troubleshooting)
337
+ If the gem doesn't work as expected, start by setting `LISTEN_GEM_DEBUGGING=debug` or `LISTEN_GEM_DEBUGGING=info` as described above in [Logging and Debugging](#logging-and-debugging).
236
338
 
339
+ *NOTE: without providing the output after setting the `LISTEN_GEM_DEBUGGING=debug` environment variable, it is usually impossible to guess why `listen` is not working as expected.*
340
+
341
+ #### 3 steps before you start diagnosing problems
342
+ These 3 steps will:
343
+
344
+ - help quickly troubleshoot obscure problems (trust me, most of them are obscure)
345
+ - help quickly identify the area of the problem (a full list is below)
346
+ - help you get familiar with listen's diagnostic mode (it really comes in handy, trust me)
347
+ - help you create relevant output before you submit an issue (so we can respond with answers instead of tons of questions)
348
+
349
+ Step 1 - The most important option in Listen
350
+ For effective troubleshooting set the `LISTEN_GEM_DEBUGGING=info` variable before starting `listen`.
351
+
352
+ Step 2 - Verify polling works
353
+ Polling has to work ... or something is really wrong (and we need to know that before anything else).
354
+
355
+ (see force_polling option).
356
+
357
+ After starting `listen`, you should see something like:
358
+ ```
359
+ INFO -- : Record.build(): 0.06773114204406738 seconds
360
+ ```
361
+ Step 3 - Trigger some changes directly without using editors or apps
362
+ Make changes e.g. touch foo or echo "a" >> foo (for troubleshooting, avoid using an editor which could generate too many misleading events).
363
+
364
+ You should see something like:
365
+ ```
366
+ INFO -- : listen: raw changes: [[:added, "/home/me/foo"]]
367
+ INFO -- : listen: final changes: {:modified=>[], :added=>["/home/me/foo"], :removed=>[]}
368
+ ```
369
+ "raw changes" contains changes collected during the :wait_for_delay and :latency intervals, while "final changes" is what listen decided are relevant changes (for better editor support).
237
370
 
238
371
  ## Performance
239
372
 
240
- If Listen seems slow or unresponsive, make sure you're not using the Polling adapter (you should see a warning upon startup if you are).
373
+ If `listen` seems slow or unresponsive, make sure you're not using the Polling adapter (you should see a warning upon startup if you are).
241
374
 
242
375
  Also, if the directories you're watching contain many files, make sure you're:
243
376
 
244
377
  * not using Polling (ideally)
245
378
  * using `:ignore` and `:only` options to avoid tracking directories you don't care about (important with Polling and on MacOS)
246
- * running Listen with the `:latency` and `:wait_for_delay` options not too small or too big (depends on needs)
379
+ * running `listen` with the `:latency` and `:wait_for_delay` options not too small or too big (depends on needs)
247
380
  * not watching directories with log files, database files or other frequently changing files
248
- * not using a version of Listen prior to 2.7.7
249
- * not getting silent crashes within Listen (see LISTEN_GEM_DEBUGGING=2)
250
- * not running multiple instances of Listen in the background
381
+ * not using a version of `listen` prior to 2.7.7
382
+ * not getting silent crashes within `listen` (see `LISTEN_GEM_DEBUGGING=debug`)
383
+ * not running multiple instances of `listen` in the background
251
384
  * using a file system with atime modification disabled (ideally)
252
385
  * not using a filesystem with inaccurate file modification times (ideally), e.g. HFS, VFAT
253
386
  * not buffering to a slow terminal (e.g. transparency + fancy font + slow gfx card + lots of output)
254
387
  * ideally not running a slow encryption stack, e.g. btrfs + ecryptfs
255
388
 
256
- When in doubt, LISTEN_GEM_DEBUGGING=2 can help discover the actual events and time they happened.
389
+ When in doubt, `LISTEN_GEM_DEBUGGING=debug` can help discover the actual events and time they happened.
390
+
391
+ ## Tips and Techniques
392
+ - Watch only directories you're interested in.
393
+ - Set your editor to save quickly (e.g. without backup files, without atomic-save)
394
+ - Tweak the `:latency` and `:wait_for_delay` options until you get good results (see [options](#options)).
395
+ - Add `:ignore` rules to silence all events you don't care about (reduces a lot of noise, especially if you use it on directories)
257
396
 
258
397
  ## Development
259
398
 
@@ -271,11 +410,29 @@ Pull requests are very welcome! Please try to follow these simple rules if appli
271
410
  For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
272
411
  `#guard` (irc.freenode.net).
273
412
 
413
+ ## Releasing
414
+
415
+ ### Prerequisites
416
+
417
+ * You must have commit rights to the GitHub repository.
418
+ * You must have push rights for rubygems.org.
419
+
420
+ ### How to release
421
+
422
+ 1. Run `bundle install` to make sure that you have all the gems necessary for testing and releasing.
423
+ 2. **Ensure all tests are passing by running `bundle exec rake`.**
424
+ 3. Determine which would be the correct next version number according to [semver](http://semver.org/).
425
+ 4. Update the version in `./lib/listen/version.rb`.
426
+ 5. Update the version in the Install section of `./README.md` (`gem 'listen', '~> X.Y'`).
427
+ 6. Commit the version in a single commit, the message should be "Preparing vX.Y.Z"
428
+ 7. Run `bundle exec rake release:full`; this will tag, push to GitHub, and publish to rubygems.org.
429
+ 8. Update and publish the release notes on the [GitHub releases page](https://github.com/guard/listen/releases) if necessary
430
+
274
431
  ## Acknowledgments
275
432
 
276
433
  * [Michael Kessler (netzpirat)][] for having written the [initial specs](https://github.com/guard/listen/commit/1e457b13b1bb8a25d2240428ce5ed488bafbed1f).
277
434
  * [Travis Tilley (ttilley)][] for this awesome work on [fssm][] & [rb-fsevent][].
278
- * [Nathan Weizenbaum (nex3)][] for [rb-inotify][], a thorough inotify wrapper.
435
+ * [Natalie Weizenbaum (nex3)][] for [rb-inotify][], a thorough inotify wrapper.
279
436
  * [Mathieu Arnold (mat813)][] for [rb-kqueue][], a simple kqueue wrapper.
280
437
  * [Maher Sallam][] for [wdm][], windows support wouldn't exist without him.
281
438
  * [Yehuda Katz (wycats)][] for [vigilo][], that has been a great source of inspiration.
@@ -295,7 +452,7 @@ For questions please join us in our [Google group](http://groups.google.com/grou
295
452
  [fssm]: https://github.com/ttilley/fssm
296
453
  [rb-fsevent]: https://github.com/thibaudgg/rb-fsevent
297
454
  [Mathieu Arnold (mat813)]: https://github.com/mat813
298
- [Nathan Weizenbaum (nex3)]: https://github.com/nex3
455
+ [Natalie Weizenbaum (nex3)]: https://github.com/nex3
299
456
  [rb-inotify]: https://github.com/nex3/rb-inotify
300
457
  [stereobooster]: https://github.com/stereobooster
301
458
  [rb-fchange]: https://github.com/stereobooster/rb-fchange
data/bin/listen CHANGED
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'listen'
4
5
  require 'listen/cli'
5
6
 
6
- unless defined?(JRUBY_VERSION)
7
- if Signal.list.keys.include?('INT')
8
- Signal.trap('INT') { Thread.new { Listen.stop } }
9
- end
7
+ if !defined?(JRUBY_VERSION) && Signal.list.keys.include?('INT')
8
+ Signal.trap('INT') { Thread.new { Listen.stop } }
10
9
  end
11
10
 
12
11
  Listen::CLI.start