{"record":{"id":"8c6e33a885372ee8","repo":"emilk/egui","slug":"notfound","errorCode":"NotFound","errorMessage":"kittest.toml not found","messagePattern":"kittest\\.toml not found","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/egui_kittest/src/config.rs","lineNumber":80,"sourceCode":"\n    /// Override the maximum number of failing pixels for this OS.\n    #[serde(alias = \"failed_pixel_count_threshold\")]\n    max_failed_pixels: Option<usize>,\n}\n\nfn find_kittest_toml() -> io::Result<std::path::PathBuf> {\n    let mut current_dir = std::env::current_dir()?;\n\n    loop {\n        let current_kittest = current_dir.join(\"kittest.toml\");\n        // Check if Cargo.toml exists in this directory\n        if current_kittest.exists() {\n            return Ok(current_kittest);\n        }\n\n        // Move up one directory\n        if !current_dir.pop() {\n            return Err(io::Error::new(\n                io::ErrorKind::NotFound,\n                \"kittest.toml not found\",\n            ));\n        }\n    }\n}\n\n/// The old name of `max_failed_pixels` is still accepted, but warned about.\nfn warn_about_deprecated_keys(config_str: &str) {\n    let Ok(config) = toml::from_str::<toml::Table>(config_str) else {\n        return;\n    };\n\n    let mut sections = vec![(\"\", &config)];\n    for name in [\"windows\", \"mac\", \"linux\"] {\n        if let Some(table) = config.get(name).and_then(toml::Value::as_table) {\n            sections.push((name, table));\n        }","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/emilk/egui/blob/441971a776322a482e371775219380eca812cfa9/crates/egui_kittest/src/config.rs#L62-L98","documentation":"`find_kittest_toml` walks up the directory tree from the current directory looking for a `kittest.toml` config file; if it reaches the filesystem root without finding one, it returns an `io::Error` with `ErrorKind::NotFound`. Kittest requires this file (even if minimal) to load snapshot/tolerance configuration.","triggerScenarios":"Running tests with `load_config` from a working directory that is not inside (or below) a directory containing `kittest.toml` — e.g. running a single test binary from `target/debug/deps`, running from the repo root when the file only exists in a crate subdirectory, or simply never having created the file.","commonSituations":"CI invoking tests with a different CWD than local runs; monorepo where the config lives in `crates/foo/` but tests run from `/`; fresh clone missing the dotfile-style config; Docker containers running the test binary from `/`.","solutions":["Create a `kittest.toml` in the directory you run tests from (or the crate root) with at least an empty config.","Run tests with the crate directory as working directory (e.g. `cargo test -p mycrate` from that directory, or set `current_dir` in CI).","In CI, add a step to `cd` into the crate root before running the test binary.","Copy the `kittest.toml` from a sibling crate or the kittest docs as a starting template."],"exampleFix":"// before (CI run from repo root, no config found)\n- run: cargo test --all\n// after\n- run: cd crates/my_crate && cargo test\n// and add crates/my_crate/kittest.toml with e.g.:\n// snapshot_path = \"snapshots\"","handlingStrategy":"validation","validationCode":"// Check the search path before loading\nif !std::path::Path::new(\"kittest.toml\").exists() {\n    eprintln!(\"kittest.toml missing from current dir; run from crate root\");\n}","typeGuard":null,"tryCatchPattern":"match Config::load() {\n    Ok(cfg) => cfg,\n    Err(e) if e.kind() == std::io::ErrorKind::NotFound => {\n        eprintln!(\"kittest.toml not found — running from crate root? using defaults\");\n        Config::default()\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Commit a kittest.toml to every crate that uses kittest.","In CI, run tests with the crate directory as the working directory.","In spawned test harnesses, set `std::env::set_current_dir` to the crate root before loading config."],"tags":["io","configuration","testing","rust"],"backgroundTag":"config-file-not-found","analyzedSha":"441971a776322a482e371775219380eca812cfa9","analyzedAt":"2026-09-12T04:29:21.500Z","contentChangedAt":"2026-09-12T04:29:21.500Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}