{"record":{"id":"ab686d28d195e61a","repo":"nektos/act","slug":"compile-q-w","errorCode":null,"errorMessage":"compile %q: %w","messagePattern":"compile %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/root.go","lineNumber":770,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc watchAndRun(ctx context.Context, fn common.Executor) error {\n\tdir, err := os.Getwd()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tignoreFile := filepath.Join(dir, \".gitignore\")\n\tignore := &gitignore.GitIgnore{}\n\tif info, err := os.Stat(ignoreFile); err == nil && !info.IsDir() {\n\t\tignore, err = gitignore.CompileIgnoreFile(ignoreFile)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"compile %q: %w\", ignoreFile, err)\n\t\t}\n\t}\n\n\tfolderWatcher := fswatch.NewFolderWatcher(\n\t\tdir,\n\t\ttrue,\n\t\tignore.MatchesPath,\n\t\t2, // 2 seconds\n\t)\n\n\tfolderWatcher.Start()\n\tdefer folderWatcher.Stop()\n\n\t// run once before watching\n\tif err := fn(ctx); err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":752,"sourceCodeEnd":788,"githubUrl":"https://github.com/nektos/act/blob/4f411281417e88660bea1c1a1749aa71ae0bd60f/cmd/root.go#L752-L788","documentation":"In watch mode (act --watch), watchAndRun compiles the repository's .gitignore (if present) with gitignore.CompileIgnoreFile to filter which file changes trigger re-runs. If that file exists but cannot be compiled as a gitignore pattern set — unreadable bytes, invalid patterns the library rejects — the wrapped error 'compile <path>: %w' is returned and watch mode exits before starting the folder watcher.","triggerScenarios":"Running 'act --watch' in a repo whose .gitignore contains lines the gitignore compiler cannot parse, or that has permission/encoding problems (non-UTF-8 bytes, a directory in place of the file is excluded by the IsDir check, but unreadable perms are not).","commonSituations":"Corrupted or oddly-encoded .gitignore (CRLF/BOM usually fine, but binary junk breaks it); tools that rewrite .gitignore badly; restrictive file permissions after a repo copy; pathologically long or malformed glob lines.","solutions":["Inspect and fix the .gitignore: remove or correct the offending pattern lines (look around the point the underlying error text mentions).","Sanitize encoding: ensure the file is valid UTF-8 text (e.g. 'file .gitignore', re-save as UTF-8).","Temporarily rename .gitignore away to confirm it is the culprit, then restore it cleaned.","If the file is not needed, delete it — watch mode only compiles it when present."],"exampleFix":"# before\n# .gitignore contains a bad line like:\n**/[]invalid[\nact --watch   # compile \"/repo/.gitignore\": ...\n\n# after\n# fix or remove the invalid pattern, then:\nact --watch","handlingStrategy":"try-catch","validationCode":"package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"unicode/utf8\"\n)\n\nfunc checkGitignoreReadable(path string) error {\n\tinfo, err := os.Stat(path)\n\tif err != nil || info.IsDir() {\n\t\treturn nil // absent is fine; watch mode skips it\n\t}\n\tdata, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\".gitignore unreadable: %w\", err)\n\t}\n\tif !utf8.Valid(data) {\n\t\treturn fmt.Errorf(\".gitignore is not valid UTF-8\")\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := watchAndRun(ctx, executor); err != nil {\n    var compileErr *fmt.wrapError\n    if errors.As(err, &compileErr) || strings.Contains(err.Error(), \"compile \\\"\") {\n        return fmt.Errorf(\"fix or remove the malformed .gitignore, then rerun act --watch: %w\", err)\n    }\n    return err\n}","preventionTips":["Keep .gitignore plain UTF-8 text with standard glob syntax.","Re-validate .gitignore after tooling rewrites it.","Rename .gitignore away temporarily to confirm it blocks 'act --watch'."],"tags":["watch-mode","gitignore","configuration","cli"],"backgroundTag":null,"analyzedSha":"4f411281417e88660bea1c1a1749aa71ae0bd60f","analyzedAt":"2026-08-15T09:19:46.307Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}