{"record":{"id":"a28b43c263622c11","repo":"docker/compose","slug":"newwatcher-w-a28b43","errorCode":null,"errorMessage":"newWatcher: %w","messagePattern":"newWatcher: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/watch/watcher_naive.go","lineNumber":323,"sourceCode":"\t\t\t\t\"Run 'sysctl fs.inotify.max_user_instances' to check your inotify limits.\\n\" +\n\t\t\t\t\"To raise them, run 'sudo sysctl fs.inotify.max_user_instances=1024'\")\n\t\t}\n\t\treturn nil, fmt.Errorf(\"creating file watcher: %w\", err)\n\t}\n\tMaybeIncreaseBufferSize(fsw)\n\n\terr = fsw.SetRecursive()\n\tisWatcherRecursive := err == nil\n\n\twrappedEvents := make(chan FileEvent)\n\tnotifyList := make(map[string]bool, len(paths))\n\tif isWatcherRecursive {\n\t\tpaths = pathutil.EncompassingPaths(paths)\n\t}\n\tfor _, path := range paths {\n\t\tpath, err := filepath.Abs(path)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"newWatcher: %w\", err)\n\t\t}\n\t\tnotifyList[path] = true\n\t}\n\n\twmw := &naiveNotify{\n\t\tnotifyList:         notifyList,\n\t\twatcher:            fsw,\n\t\tevents:             fsw.Events,\n\t\twrappedEvents:      wrappedEvents,\n\t\terrors:             fsw.Errors,\n\t\tisWatcherRecursive: isWatcherRecursive,\n\t}\n\twmw.addWatch = wmw.add\n\n\treturn wmw, nil\n}\n\nvar _ Notify = &naiveNotify{}","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/watch/watcher_naive.go#L305-L341","documentation":"On the naive watcher path, newWatcher records each (possibly EncompassingPaths-merged) path as absolute before building the notifyList. filepath.Abs fails only when the process working directory is gone or unreadable, exactly like the darwin variant — relative paths cannot be resolved without a valid cwd. The newWatcher prefix marks the construction site.","triggerScenarios":"newWatcher(paths) on Linux/other platforms where isWatcherRecursive collapsed paths via EncompassingPaths, one is relative, and getwd() fails because the cwd was deleted (common when the watched project directory is removed by a clean step while the shell still sits in it).","commonSituations":"`make clean`/`git clean -xfd` removing the directory the terminal was in; temp-dir-based CI jobs purged mid-run; scripts cd-ing into soon-deleted build output dirs before starting compose watch.","solutions":["Change back to an existing directory (`cd ~/project`) and rerun the command.","Make clean targets delete directory contents, never the watched directory itself.","Recreate the deleted directory if the workflow depends on watching it from inside."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// fail fast when cwd is gone (same check the watcher needs)\nwd, err := os.Getwd()\nif err != nil { return err }\nif _, err := os.Lstat(wd); err != nil {\n    return fmt.Errorf(\"current directory %q disappeared; cd back into the project\", wd)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Start watch commands from a stable directory (project root), not from generated build dirs.","Make clean scripts delete contents rather than the watched directory itself.","Re-cd into the project after destructive git operations before starting watchers."],"tags":["go","docker-compose","watch","filesystem","cwd","linux"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}