watch: improve error messages when you run out of inotify instances (#3960)

This commit is contained in:
Nick Santos 2020-12-03 15:44:11 -05:00 committed by Nicolas De loof
parent c7ba7d9de5
commit 28251e8be5
1 changed files with 8 additions and 1 deletions

View File

@ -6,6 +6,8 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"strings"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/tilt-dev/fsnotify" "github.com/tilt-dev/fsnotify"
@ -261,7 +263,12 @@ func newWatcher(paths []string, ignore PathMatcher, l logger.Logger) (*naiveNoti
fsw, err := fsnotify.NewWatcher() fsw, err := fsnotify.NewWatcher()
if err != nil { 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) MaybeIncreaseBufferSize(fsw)