From 28251e8be5a9893965bd60fe99f1448a58e83414 Mon Sep 17 00:00:00 2001 From: Nick Santos Date: Thu, 3 Dec 2020 15:44:11 -0500 Subject: [PATCH] watch: improve error messages when you run out of inotify instances (#3960) --- pkg/watch/watcher_naive.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/watch/watcher_naive.go b/pkg/watch/watcher_naive.go index 637ac88cb..58e9def66 100644 --- a/pkg/watch/watcher_naive.go +++ b/pkg/watch/watcher_naive.go @@ -6,6 +6,8 @@ import ( "fmt" "os" "path/filepath" + "runtime" + "strings" "github.com/pkg/errors" "github.com/tilt-dev/fsnotify" @@ -261,7 +263,12 @@ func newWatcher(paths []string, ignore PathMatcher, l logger.Logger) (*naiveNoti fsw, err := fsnotify.NewWatcher() if err != nil { - return nil, err + if strings.Contains(err.Error(), "too many open files") && runtime.GOOS == "linux" { + return nil, fmt.Errorf("Hit OS limits creating a watcher.\n" + + "Run 'sysctl fs.inotify.max_user_instances' to check your inotify limits.\n" + + "To raise them, run 'sudo sysctl fs.inotify.max_user_instances=1024'") + } + return nil, errors.Wrap(err, "creating file watcher") } MaybeIncreaseBufferSize(fsw)