{"record":{"id":"b763f12f77094b2a","repo":"charmbracelet/crush","slug":"ripgrep-w-n-s","errorCode":null,"errorMessage":"ripgrep: %w\\n%s","messagePattern":"ripgrep: %w\\\\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/glob.go","lineNumber":178,"sourceCode":"\t\tif err != nil {\n\t\t\tbreak // EOF or read error; drain handled by Wait below.\n\t\t}\n\t\tif len(matches) >= candidatePool {\n\t\t\t// Enough candidates; stop reading and let the process be\n\t\t\t// killed by the command context / Wait. Draining the rest\n\t\t\t// would just buffer paths we are going to discard.\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Close our end so ripgrep gets SIGPIPE and stops, then reap it.\n\t_ = stdout.Close()\n\twaitErr := cmd.Wait()\n\tif waitErr != nil && len(matches) == 0 {\n\t\tif ee, ok := waitErr.(*exec.ExitError); ok && ee.ExitCode() == 1 {\n\t\t\treturn nil, nil // No matches.\n\t\t}\n\t\treturn nil, fmt.Errorf(\"ripgrep: %w\\n%s\", waitErr, stderr.String())\n\t}\n\n\tsort.SliceStable(matches, func(i, j int) bool {\n\t\treturn len(matches[i]) < len(matches[j])\n\t})\n\n\tif limit > 0 && len(matches) > limit {\n\t\tmatches = matches[:limit]\n\t}\n\treturn matches, nil\n}\n\nfunc normalizeFilePaths(paths []string) {\n\tfor i, p := range paths {\n\t\tpaths[i] = filepath.ToSlash(p)\n\t}\n}\n","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/agent/tools/glob.go#L160-L196","documentation":"The ripgrep process exited with a failure after producing zero matches. Exit code 1 is treated as 'no matches' and returns nil; any other non-zero exit (or a non-ExitError failure) is reported here along with ripgrep's stderr output for diagnosis.","triggerScenarios":"cmd.Wait() returns a waitErr that is not ExitError with code 1: ripgrep exit code 2 (regex parse error, invalid flag, unreadable path with strict mode), signal termination, or a non-ExitError Wait failure — and no matches were collected.","commonSituations":"Invalid glob include pattern passed to rg --glob, corrupted regex, ripgrep crashing (OOM/killed), searching a path rg cannot access, or stderr carrying config-file (RIPGREP_CONFIG_PATH) errors.","solutions":["Read the stderr text appended to the error — it contains ripgrep's own diagnostic","Validate the include/glob pattern and search path for typos","Test the equivalent command manually (`rg --files --glob '<pattern>' <path>`) to reproduce","Check RIPGREP_CONFIG_PATH for a user config injecting bad flags"],"exampleFix":"// before\nwaitErr := cmd.Wait()\nif waitErr != nil && len(matches) == 0 {\n    if ee, ok := waitErr.(*exec.ExitError); ok && ee.ExitCode() == 1 {\n        return nil, nil\n    }\n    return nil, fmt.Errorf(\"ripgrep: %w\\n%s\", waitErr, stderr.String())\n}\n// after\nwaitErr := cmd.Wait()\nif waitErr != nil && len(matches) == 0 {\n    var ee *exec.ExitError\n    if errors.As(waitErr, &ee) && ee.ExitCode() == 1 {\n        return nil, nil\n    }\n    return nil, fmt.Errorf(\"ripgrep: %w\\n%s\", waitErr, strings.TrimSpace(stderr.String()))\n}","handlingStrategy":"type-guard","validationCode":"null","typeGuard":"var ee *exec.ExitError\nif errors.As(waitErr, &ee) && ee.ExitCode() == 1 {\n    // no matches — not an error\n}","tryCatchPattern":"waitErr := cmd.Wait()\nif waitErr != nil && len(matches) == 0 {\n    var ee *exec.ExitError\n    if errors.As(waitErr, &ee) && ee.ExitCode() == 1 {\n        return nil, nil\n    }\n    return nil, fmt.Errorf(\"ripgrep: %w\\n%s\", waitErr, stderr.String())\n}","preventionTips":["Always read the appended stderr for ripgrep's own diagnostic","Validate glob/regex patterns before passing to rg","Reproduce with the raw rg command from the error to isolate bad flags","Clear RIPGREP_CONFIG_PATH if a user config injects invalid flags"],"tags":["ripgrep","exec","exit-code","glob"],"backgroundTag":"ripgrep-exit-error","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}