{"record":{"id":"7fa700647c69143d","repo":"getzola/zola","slug":"is-not-an-empty-folder-hidden-files-are-igno","errorCode":null,"errorMessage":"`{}` is not an empty folder (hidden files are ignored).","messagePattern":"`(.+?)` is not an empty folder \\(hidden files are ignored\\)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/init.rs","lineNumber":78,"sourceCode":"\n    Ok(false)\n}\n\n// Remove the unc part of a windows path\nfn strip_unc(path: &Path) -> String {\n    let path_to_refine = path.to_str().unwrap();\n    path_to_refine.trim_start_matches(LOCAL_UNC).to_string()\n}\n\npub fn create_new_project(name: &str, force: bool) -> Result<()> {\n    let path = Path::new(name);\n\n    // Better error message than the rust default\n    if path.exists() && !is_directory_quasi_empty(path)? && !force {\n        if name == \".\" {\n            bail!(\"The current directory is not an empty folder (hidden files are ignored).\");\n        } else {\n            bail!(\"`{}` is not an empty folder (hidden files are ignored).\", path.to_string_lossy())\n        }\n    }\n\n    console::info(\"Welcome to Zola!\");\n    console::info(\"Please answer a few questions to get started quickly.\");\n    console::info(\"Any choices made can be changed by modifying the `zola.toml` file later.\");\n\n    let base_url = ask_url(\"> What is the URL of your site?\", \"https://example.com\")?;\n    let compile_sass = ask_bool(\"> Do you want to enable Sass compilation?\", true)?;\n    let search = ask_bool(\"> Do you want to build a search index of the content?\", false)?;\n\n    let config = CONFIG\n        .trim_start()\n        .replace(\"%BASE_URL%\", &base_url)\n        .replace(\"%COMPILE_SASS%\", &format!(\"{compile_sass}\"))\n        .replace(\"%SEARCH%\", &format!(\"{search}\"));\n\n    populate(path, compile_sass, &config)?;","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/src/cmd/init.rs#L60-L96","documentation":"Thrown by `zola init` when the target project directory already contains files. Zola refuses to initialize into a non-empty folder to avoid overwriting user files; hidden files (dotfiles) are ignored when checking emptiness. The `--force` flag bypasses this check.","triggerScenarios":"Running `zola init <path>` (or `zola init .`) when `path` exists, is not quasi-empty (contains at least one non-hidden entry), and `--force` was not passed.","commonSituations":"Re-running `zola init` in a directory that already has a site or stray files (e.g. README.md, .gitignore counted only if visible, templates/, content/); accidentally initializing into the wrong directory; init interrupted previously leaving files behind.","solutions":["Remove or move out the existing files in the target directory, or pick a new empty directory","If you intentionally want to initialize over existing content, re-run with `zola init <path> --force`","Use `ls -A` to inspect the directory; note hidden files alone do not block init"],"exampleFix":"// before\n$ zola init .\nError: `.` is not an empty folder (hidden files are ignored).\n// after\n$ ls -A   # remove/move stray visible files\n$ zola init . --force   # or clean the directory first","handlingStrategy":"validation","validationCode":"import std::fs;\nfn dir_is_quasi_empty(p: &Path) -> bool {\n    std::fs::read_dir(p).map(|it| it.filter_map(|e| e.ok()).all(|e| e.file_name().to_string_lossy().starts_with('.'))).unwrap_or(true)\n}\nif path.exists() && !dir_is_quasi_empty(path) && !force { /* abort or pass --force */ }","typeGuard":"fn is_init_safe(path: &Path, force: bool) -> bool { force || !path.exists() || dir_is_quasi_empty(path) }","tryCatchPattern":null,"preventionTips":["Run `ls -A <dir>` before `zola init` to confirm it is empty or only has dotfiles","Use `--force` deliberately when initializing over an existing scaffold","Initialize in a fresh directory first, then move existing content in"],"tags":["cli","init","filesystem"],"backgroundTag":"non-empty-directory","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"}