wasmerio/wasmer · error · anyhow::Error
Stopping as the directory is not empty
Error message
Stopping as the directory is not empty
What it means
get_output_dir checks whether the chosen output directory is empty before scaffolding an app. If it is not empty (and the user is not quiet/interactive-confirming), it bails with 'Stopping as the directory is not empty' to avoid clobbering existing files with template/package contents.
Source
Thrown at lib/cli/src/commands/app/create.rs:242
crate::utils::prompts::prompt_for_namespace("Who should own this app?", None, user.as_ref())
}
async fn get_output_dir(&self, app_name: &str) -> anyhow::Result<PathBuf> {
let mut output_path = if let Some(path) = &self.app_dir_path {
path.clone()
} else {
PathBuf::from(".").canonicalize()?
};
if output_path.is_dir() && output_path.read_dir()?.next().is_some() {
if self.non_interactive {
if !self.quiet {
eprintln!("The current directory is not empty.");
eprintln!(
"Use the `--dir` flag to specify another directory, or remove files from the currently selected one."
)
}
anyhow::bail!("Stopping as the directory is not empty")
} else {
let theme = ColorfulTheme::default();
let raw: String = dialoguer::Input::with_theme(&theme)
.with_prompt("Select the directory to save the app in")
.with_initial_text(app_name)
.interact_text()
.context("could not read user input")?;
output_path = PathBuf::from_str(&raw)?
}
}
Ok(output_path)
}
async fn create_from_local_manifest(
&self,
owner: &str,
app_name: &str,View on GitHub (pinned to 8c4b9ee9d3)
Solutions
- Pass --dir /path/to/empty-directory to scaffold somewhere else.
- Clean the target directory (move/delete existing files) before re-running.
- Run the command in a fresh empty directory.
Example fix
// before // wasmer app create --template my-template (run in non-empty dir) // after // wasmer app create --template my-template --dir ./my-new-app
Defensive patterns
Strategy: validation
Validate before calling
import fs from 'fs';
const dir = args.dir ?? process.cwd();
if (fs.readdirSync(dir).length > 0) {
throw new Error(`target directory ${dir} is not empty; use --dir`);
} Type guard
fn dir_is_empty(p: &Path) -> std::io::Result<bool> {
Ok(std::fs::read_dir(p)?.next().is_none())
} Try / catch
match result {
Err(e) if e.to_string().contains("directory is not empty") => {
eprintln!("retrying with --dir ./new-app");
// re-invoke command with --dir
}
other => other?,
} Prevention
- Always scaffold into a fresh empty directory (use --dir).
- Check directory contents before running app create.
- Avoid running create commands inside existing project roots.
When it happens
Trigger: Running `wasmer app create` (from package or template) targeting a directory (default: current directory) that already contains files, without --dir pointing elsewhere.
Common situations: Running the command inside an existing project folder or git repo; re-running create after a partial failure; forgetting the --dir flag.
Related errors
- The --use_local_manifest flag was passed, but path {} does n
- No template selected
- Cannot create app from template in offline mode
- No app name specified: use --name <app_name>
- No owner specified: use --owner <owner>
AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01).
Data as JSON: /api/errors/379b72f6cc3da67d.
Report an issue: GitHub.