{"record":{"id":"59d2e6c85e81516f","repo":"getzola/zola","slug":"the-current-directory-is-not-an-empty-folder-hidd","errorCode":null,"errorMessage":"The current directory is not an empty folder (hidden files are ignored).","messagePattern":"The current directory is not an empty folder \\(hidden files are ignored\\)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/init.rs","lineNumber":76,"sourceCode":"        return Ok(true);\n    }\n\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}\"));","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/src/cmd/init.rs#L58-L94","documentation":"`create_new_project` refuses to initialize into an existing, non-empty directory unless `--force` is passed. Hidden files (starting with `.`) are ignored, so a directory containing only dotfiles counts as empty. When the target is the current directory (`name == \".\"`) this generic message is shown; otherwise the path is named.","triggerScenarios":"Running `zola init .` (or a named path) where the directory exists, `is_directory_quasi_empty` returns false (contains at least one non-hidden file), and `force` is false.","commonSituations":"Initializing into a folder that already has files (previous project, downloaded files, notes); running init in the wrong directory by mistake.","solutions":["Run `zola init . --force` (or `zola init <name> --force`) to overwrite/initialize anyway","Move or delete the non-hidden files out of the directory first","Initialize into a new empty directory instead"],"exampleFix":"// before\n$ zola init .\n// after\n$ zola init . --force   # or clear the directory first","handlingStrategy":"validation","validationCode":"fn init_target_clear(name: &str, force: bool) -> bool {\n    let p = Path::new(name);\n    force || !p.exists()\n        || p.read_dir().map_or(false, |mut it| it.all(|e| e.map(|f| f.file_name().to_string_lossy().starts_with('.')).unwrap_or(false)))\n}","typeGuard":null,"tryCatchPattern":"match create_new_project(name, force) {\n    Ok(_) => {},\n    Err(e) if e.to_string().contains(\"is not an empty folder\") => {\n        eprintln!(\"pass --force or clean the directory first\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Initialize only into empty (or dotfiles-only) directories","Use --force deliberately when overwriting is intended","Double-check the working directory before `zola init .`"],"tags":["rust","zola","init","directory-not-empty"],"backgroundTag":"directory-not-empty","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"}