Skip to content

Commit 28251e8

Browse files
nicksndeloof
authored andcommitted
watch: improve error messages when you run out of inotify instances (docker#3960)
1 parent c7ba7d9 commit 28251e8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/watch/watcher_naive.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"fmt"
77
"os"
88
"path/filepath"
9+
"runtime"
10+
"strings"
911

1012
"github.com/pkg/errors"
1113
"github.com/tilt-dev/fsnotify"
@@ -261,7 +263,12 @@ func newWatcher(paths []string, ignore PathMatcher, l logger.Logger) (*naiveNoti
261263

262264
fsw, err := fsnotify.NewWatcher()
263265
if err != nil {
264-
return nil, err
266+
if strings.Contains(err.Error(), "too many open files") && runtime.GOOS == "linux" {
267+
return nil, fmt.Errorf("Hit OS limits creating a watcher.\n" +
268+
"Run 'sysctl fs.inotify.max_user_instances' to check your inotify limits.\n" +
269+
"To raise them, run 'sudo sysctl fs.inotify.max_user_instances=1024'")
270+
}
271+
return nil, errors.Wrap(err, "creating file watcher")
265272
}
266273
MaybeIncreaseBufferSize(fsw)
267274

0 commit comments

Comments
 (0)