{"record":{"id":"3a181bbcff3be5ba","repo":"getzola/zola","slug":"not-found-in-current-directory-or-ancestors-cu","errorCode":null,"errorMessage":"{} not found in current directory or ancestors, current_dir is {}","messagePattern":"(.+?) not found in current directory or ancestors, current_dir is (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":26,"sourceCode":"use utils::net::{get_available_port, port_is_available};\n\nuse clap::{CommandFactory, Parser};\nuse time::UtcOffset;\n\nmod cli;\nmod cmd;\nmod fs_utils;\nmod messages;\nmod prompt;\n\nfn get_config_file_path(dir: &Path, config_path: Option<&Path>) -> (PathBuf, PathBuf) {\n    let (root_dir, config_path) = match config_path {\n        Some(path) => {\n            // User specified a config file, use it directly\n            let root = dir.ancestors().find(|a| a.join(path).exists()).unwrap_or_else(|| {\n                messages::unravel_errors(\n                    \"\",\n                    &anyhow!(\n                        \"{} not found in current directory or ancestors, current_dir is {}\",\n                        path.display(),\n                        dir.display()\n                    ),\n                );\n                std::process::exit(1);\n            });\n            (root, path.to_path_buf())\n        }\n        None => {\n            // Try zola.toml first, then fall back to config.toml\n            let zola_config = Path::new(\"zola.toml\");\n            let legacy_config = Path::new(\"config.toml\");\n\n            if let Some(root) = dir.ancestors().find(|a| a.join(zola_config).exists()) {\n                (root, zola_config.to_path_buf())\n            } else if let Some(root) = dir.ancestors().find(|a| a.join(legacy_config).exists()) {\n                (root, legacy_config.to_path_buf())","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/src/main.rs#L8-L44","documentation":"get_config_file_path resolves the config file: when the user passed an explicit --config path, Zola walks up from the current directory through ancestors looking for a directory containing that file. If none is found, it prints this error via unravel_errors and exits the process with code 1.","triggerScenarios":"Running any zola command with an explicit --config CONFIG (e.g. --config config.production.toml) where neither the current directory nor any ancestor contains that file — wrong working directory, misspelled config name, or file outside the ancestor chain.","commonSituations":"CI jobs running zola from the repo root while the custom config lives in a subfolder; renaming the config file but forgetting to update the --config flag; passing a path that exists elsewhere but not in the ancestor chain of the cwd.","solutions":["cd to the directory that actually contains the named config file before running zola","Fix the --config argument spelling/path, or pass a path relative to the current directory that resolves","Verify the file exists: ls path/to/your-config.toml","If you meant the default config, drop the --config flag so Zola looks for zola.toml/config.toml"],"exampleFix":"// before\nzola build --config production.toml   # file only in ./config/\n// after\nzola build --config config/production.toml","handlingStrategy":"validation","validationCode":"// shell: fail fast with a clear message before invoking zola\nCONFIG=\"${ZOLA_CONFIG:-config/production.toml}\"\n[ -f \"$CONFIG\" ] || { echo \"config not found: $CONFIG\"; exit 1; }\nzola build --config \"$CONFIG\"","typeGuard":null,"tryCatchPattern":"// shell\nif ! zola build --config \"$CFG\"; then\n  echo \"Check --config path; it must exist in cwd or an ancestor\"\nfi","preventionTips":["Always pass --config relative to your current directory","Add a CI step asserting the config file exists before running zola","Keep custom configs at the repo root so ancestor search finds them"],"tags":["rust","cli","config","startup"],"backgroundTag":"config-file-not-found","analyzedSha":"61d30828217957120309db657950224edf9707e2","analyzedAt":"2026-09-03T14:39:09.727Z","contentChangedAt":"2026-09-03T14:39:09.727Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}