{"record":{"id":"d53c5b6b711129d8","repo":"FuelLabs/fuels-rs","slug":"failed-grep-command","errorCode":null,"errorMessage":"failed grep command","messagePattern":"failed grep command","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/check-docs/src/lib.rs","lineNumber":240,"sourceCode":"                .expect(\"could not canonicalize md path\");\n\n            (!md_files_summary.contains(&file))\n                .then(|| anyhow!(\"file `{}` not in SUMMARY.md\", file.to_str().unwrap()))\n        })\n        .collect()\n}\n\npub fn search_for_pattern(pattern: &str, location: &str) -> anyhow::Result<String> {\n    let grep_project = std::process::Command::new(\"grep\")\n        .arg(\"-H\") // print filename\n        .arg(\"-n\") // print line-number\n        .arg(\"-r\") // search recursively\n        .arg(\"--binary-files=without-match\")\n        .arg(\"--exclude-dir=check-docs\")\n        .arg(pattern)\n        .arg(location)\n        .output()\n        .expect(\"failed grep command\");\n\n    if !grep_project.status.success() {\n        bail!(\"Failed running `grep` command for pattern '{}'\", pattern);\n    }\n\n    Ok(String::from_utf8(grep_project.stdout)?)\n}\n\npub fn find_files(pattern: &str, location: &str, exclude: &str) -> anyhow::Result<String> {\n    let find = std::process::Command::new(\"find\")\n        .args([\n            location, \"-type\", \"f\", \"-name\", pattern, \"!\", \"-name\", exclude,\n        ])\n        .output()\n        .expect(\"Program `find` not in PATH\");\n\n    if !find.status.success() {\n        bail!(\"Failed running `find` command for pattern {}\", pattern);","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/FuelLabs/fuels-rs/blob/d9a250a51818dda64bfeb5ef7cc19cf27bdcd623/scripts/check-docs/src/lib.rs#L222-L258","documentation":"check-docs shells out to the grep binary via std::process::Command and expects the spawn itself to succeed. The expect fires when grep cannot be spawned at all, most commonly because grep is not installed or not on PATH. A grep that runs but exits non-zero is a different, separately handled error (bail!).","triggerScenarios":"Running check-docs in a minimal container image (distroless, scratch-based) without grep installed, or with a PATH scrubbed by the CI environment so Command::new(\"grep\") cannot resolve the binary.","commonSituations":"Lean CI images lacking core utilities; PATH misconfiguration; cross-environment script runs.","solutions":["Install grep in the execution image (apt-get install -y grep / apk add grep)","Run the script in the CI image that already ships core utilities","Fix PATH if grep exists on disk but is not found"],"exampleFix":"# before: minimal image without coreutils\nRUN cargo run -p scripts/check-docs\n\n# after: install grep first\nRUN apt-get update && apt-get install -y grep\ncargo run -p scripts/check-docs","handlingStrategy":"fallback","validationCode":"# (shell) availability check before running check-docs\ncommand -v grep >/dev/null || { echo 'grep is required by check-docs'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install grep in the CI image running docs checks","Or replace the external grep call with an in-Rust search (walkdir + regex) to remove the system dependency","Document the tool's system requirements in the script README"],"tags":["docs","ci","shell","dependencies","scripting"],"backgroundTag":null,"analyzedSha":"d9a250a51818dda64bfeb5ef7cc19cf27bdcd623","analyzedAt":"2026-08-16T09:49:30.618Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}