{"record":{"id":"f397b7a0ccaf04d0","repo":"phiresky/ripgrep-all","slug":"config-file-not-found","errorCode":null,"errorMessage":"Config file not found: {}","messagePattern":"Config file not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config.rs","lineNumber":300,"sourceCode":"                format!(\"Could not read config file json {config_filename_str}\")\n            })?;\n            let mut s = String::new();\n            json_comments::StripComments::new(raw.as_bytes())\n                .read_to_string(&mut s)\n                .context(\"strip comments\")?;\n            s\n        };\n        {\n            // just for error messages, actual deserialization happens after merging with cmd args\n            serde_json::from_str::<RgaConfig>(&config_file_contents).with_context(|| {\n                format!(\"Error in config file {config_filename_str}: {config_file_contents}\")\n            })?;\n        }\n        let config_json: serde_json::Value =\n            serde_json::from_str(&config_file_contents).context(\"Could not parse config json\")?;\n        Ok((config_filename_str, config_json))\n    } else if let Some(p) = path_override.as_ref() {\n        Err(anyhow::anyhow!(\"Config file not found: {}\", p))?\n    } else {\n        // write default config\n        std::fs::create_dir_all(config_dir)?;\n        let mut schemafile = File::create(config_dir.join(\"config.v1.schema.json\"))?;\n\n        schemafile.write_all(\n            serde_json::to_string_pretty(&schemars::schema_for!(RgaConfig))?.as_bytes(),\n        )?;\n\n        let mut configfile = File::create(config_filename)?;\n        configfile.write_all(include_str!(\"../doc/config.default.jsonc\").as_bytes())?;\n        Ok((\n            config_filename_str,\n            serde_json::Value::Object(Default::default()),\n        ))\n    }\n}\nfn read_config_env() -> Result<Value> {","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/phiresky/ripgrep-all/blob/0f10fb926e7aae676ac0877c888c939a98a78182/src/config.rs#L282-L318","documentation":"This error is thrown by read_config_file in src/config.rs when the user explicitly provided a config file path override, but the resolved path override does not exist on disk. The library only auto-creates a default config when no path override is given; when a path override IS given, a missing file is treated as a hard error instead of silently creating a default. The error message interpolates the offending path so the developer can see exactly which file was not found.","triggerScenarios":"Calling the CLI (via parse_args) with a --config style path override pointing to a file that does not exist, e.g. a typo in the path, a config file that was moved or deleted, or a relative path resolved against a different working directory.","commonSituations":"Typo in the config path flag; pointing at a config file in a repo that was gitignored and never created on a fresh clone; running from a different working directory so a relative path no longer resolves; CI environments where the config file was expected to be provisioned by a prior step that failed.","solutions":["Check that the path passed via the config override flag exists: run `ls -la <path>` (or the equivalent) to confirm the file is present.","Fix typos or update the path to the actual config file location, e.g. use the repo's config/config.v1.json rather than a stale path.","If the config lives in a fresh checkout, either restore the file or remove the override so the library falls back to writing/using the default config in config_dir.","Run the command from the intended working directory (or pass an absolute path) so relative overrides resolve correctly."],"exampleFix":"// before\nmytool --config ./confg/config.v1.json\n// after (typo fixed, and verify the file exists)\nls ./config/config.v1.json && mytool --config ./config/config.v1.json","handlingStrategy":"validation","validationCode":"fn ensure_config_exists(path: &str) -> Result<(), String> {\n    let p = std::path::Path::new(path);\n    if p.is_file() {\n        Ok(())\n    } else {\n        Err(format!(\"Config override does not exist: {}\", path))\n    }\n}","typeGuard":"fn config_file_exists(path: &str) -> bool {\n    std::path::Path::new(path).is_file()\n}","tryCatchPattern":"// Rust: handle the anyhow error at the call site\nmatch parse_args() {\n    Ok(args) => run(args),\n    Err(e) if e.to_string().starts_with(\"Config file not found:\") => {\n        eprintln!(\"{} — falling back to default config\", e);\n        run_with_default_config();\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate the config path exists before invoking the CLI, e.g. in shell: `[ -f \"$CONFIG\" ] || { echo \"missing config $CONFIG\"; exit 1; }`.","Use absolute paths for config overrides in scripts and CI so they are independent of the working directory.","Commit or provision the config file (or a template) so fresh clones/CI runners always have it.","Omit the override flag when you want the library's default-config creation behavior instead of a hard error."],"tags":["config","file-not-found","cli"],"backgroundTag":"config-file-not-found","analyzedSha":"0f10fb926e7aae676ac0877c888c939a98a78182","analyzedAt":"2026-09-10T10:01:38.203Z","contentChangedAt":"2026-09-10T10:01:38.203Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}