getzola/zola · error
The current directory is not an empty folder (hidden files a
Error message
The current directory is not an empty folder (hidden files are ignored).
What it means
`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.
Source
Thrown at src/cmd/init.rs:76
return Ok(true);
}
Ok(false)
}
// Remove the unc part of a windows path
fn strip_unc(path: &Path) -> String {
let path_to_refine = path.to_str().unwrap();
path_to_refine.trim_start_matches(LOCAL_UNC).to_string()
}
pub fn create_new_project(name: &str, force: bool) -> Result<()> {
let path = Path::new(name);
// Better error message than the rust default
if path.exists() && !is_directory_quasi_empty(path)? && !force {
if name == "." {
bail!("The current directory is not an empty folder (hidden files are ignored).");
} else {
bail!("`{}` is not an empty folder (hidden files are ignored).", path.to_string_lossy())
}
}
console::info("Welcome to Zola!");
console::info("Please answer a few questions to get started quickly.");
console::info("Any choices made can be changed by modifying the `zola.toml` file later.");
let base_url = ask_url("> What is the URL of your site?", "https://example.com")?;
let compile_sass = ask_bool("> Do you want to enable Sass compilation?", true)?;
let search = ask_bool("> Do you want to build a search index of the content?", false)?;
let config = CONFIG
.trim_start()
.replace("%BASE_URL%", &base_url)
.replace("%COMPILE_SASS%", &format!("{compile_sass}"))
.replace("%SEARCH%", &format!("{search}"));View on GitHub (pinned to 61d3082821)
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
Example fix
// before $ zola init . // after $ zola init . --force # or clear the directory first
Defensive patterns
Strategy: validation
Validate before calling
fn init_target_clear(name: &str, force: bool) -> bool {
let p = Path::new(name);
force || !p.exists()
|| 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)))
} Try / catch
match create_new_project(name, force) {
Ok(_) => {},
Err(e) if e.to_string().contains("is not an empty folder") => {
eprintln!("pass --force or clean the directory first");
}
Err(e) => return Err(e),
} Prevention
- Initialize only into empty (or dotfiles-only) directories
- Use --force deliberately when overwriting is intended
- Double-check the working directory before `zola init .`
When it happens
Trigger: 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.
Common situations: Initializing into a folder that already has files (previous project, downloaded files, notes); running init in the wrong directory by mistake.
Related errors
- Theme `{}` is missing a templates folder
- Either a `templates/` folder or a theme is required
- could not parse domain `{}` from link
- could not parse domain `{}` from link: `{}`
- Failed to convert bytes to string : {}
AI-assisted analysis of getzola/zola@61d3082821 (2026-09-03).
Data as JSON: /api/errors/59d2e6c85e81516f.
Report an issue: GitHub.