{"record":{"id":"a5f8b0ed50ac54ef","repo":"rust-lang/mdBook","slug":"chapter-not-found","errorCode":null,"errorMessage":"Chapter not found: {}","messagePattern":"Chapter not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mdbook-driver/src/mdbook.rs","lineNumber":341,"sourceCode":"                    .with_context(|| \"failed to execute `rustdoc`\")?;\n\n                if !output.status.success() {\n                    failed = true;\n                    eprintln!(\n                        \"ERROR rustdoc returned an error:\\n\\\n                        \\n--- stdout\\n{}\\n--- stderr\\n{}\",\n                        String::from_utf8_lossy(&output.stdout),\n                        String::from_utf8_lossy(&output.stderr)\n                    );\n                }\n            }\n        }\n        if failed {\n            bail!(\"One or more tests failed\");\n        }\n        if let Some(chapter) = chapter {\n            if !chapter_found {\n                bail!(\"Chapter not found: {}\", chapter);\n            }\n        }\n        Ok(())\n    }\n\n    /// The logic for determining where a backend should put its build\n    /// artefacts.\n    ///\n    /// If there is only 1 renderer, put it in the directory pointed to by the\n    /// `build.build_dir` key in [`Config`]. If there is more than one then the\n    /// renderer gets its own directory within the main build dir.\n    ///\n    /// i.e. If there were only one renderer (in this case, the HTML renderer):\n    ///\n    /// - build/\n    ///   - index.html\n    ///   - ...\n    ///","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/rust-lang/mdBook/blob/dc21064fc21d955a0e1f67e65e336883c3e5260b/crates/mdbook-driver/src/mdbook.rs#L323-L359","documentation":"When `mdbook test --chapter <name>` is given a chapter name, test_chapter() tracks whether any tested item matched it; if no chapter matched (after tests ran without failures) it bails with \"Chapter not found\".","triggerScenarios":"Running `mdbook test --chapter NAME` where NAME does not match any chapter's name (or the matching chapter contains no Rust code blocks so it is never visited).","commonSituations":"Typo in the chapter name; using the file path instead of the chapter title; renamed chapters after restructuring the book.","solutions":["Use the exact chapter name/title as it appears in SUMMARY.md","Verify the chapter contains Rust code blocks to test","Run `mdbook test` without --chapter to list/run everything and confirm the chapter exists"],"exampleFix":"// before\n$ mdbook test --chapter \"getting started\"\n// after\n$ mdbook test --chapter \"Getting Started\"","handlingStrategy":"validation","validationCode":"// before running: confirm the chapter title exists in SUMMARY.md\nlet titles: Vec<&str> = std::fs::read_to_string(\"src/SUMMARY.md\")?.lines().collect();\nassert!(titles.iter().any(|l| l.contains(chapter_name)), \"chapter not in SUMMARY.md\");","typeGuard":null,"tryCatchPattern":"if let Err(e) = book.test(&[], Some(chapter), None) {\n    if e.to_string().starts_with(\"Chapter not found\") {\n        eprintln!(\"check the exact chapter title in SUMMARY.md\");\n    }\n    std::process::exit(1);\n}","preventionTips":["Copy the chapter title exactly from SUMMARY.md (case-sensitive)","Remember --chapter matches chapter names, not file paths","Ensure the target chapter has Rust code blocks to test"],"tags":["testing","cli"],"backgroundTag":"test-failure","analyzedSha":"dc21064fc21d955a0e1f67e65e336883c3e5260b","analyzedAt":"2026-09-01T10:15:12.134Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}