{"record":{"id":"379b72f6cc3da67d","repo":"wasmerio/wasmer","slug":"stopping-as-the-directory-is-not-empty","errorCode":null,"errorMessage":"Stopping as the directory is not empty","messagePattern":"Stopping as the directory is not empty","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"lib/cli/src/commands/app/create.rs","lineNumber":242,"sourceCode":"        crate::utils::prompts::prompt_for_namespace(\"Who should own this app?\", None, user.as_ref())\n    }\n\n    async fn get_output_dir(&self, app_name: &str) -> anyhow::Result<PathBuf> {\n        let mut output_path = if let Some(path) = &self.app_dir_path {\n            path.clone()\n        } else {\n            PathBuf::from(\".\").canonicalize()?\n        };\n\n        if output_path.is_dir() && output_path.read_dir()?.next().is_some() {\n            if self.non_interactive {\n                if !self.quiet {\n                    eprintln!(\"The current directory is not empty.\");\n                    eprintln!(\n                        \"Use the `--dir` flag to specify another directory, or remove files from the currently selected one.\"\n                    )\n                }\n                anyhow::bail!(\"Stopping as the directory is not empty\")\n            } else {\n                let theme = ColorfulTheme::default();\n                let raw: String = dialoguer::Input::with_theme(&theme)\n                    .with_prompt(\"Select the directory to save the app in\")\n                    .with_initial_text(app_name)\n                    .interact_text()\n                    .context(\"could not read user input\")?;\n                output_path = PathBuf::from_str(&raw)?\n            }\n        }\n\n        Ok(output_path)\n    }\n\n    async fn create_from_local_manifest(\n        &self,\n        owner: &str,\n        app_name: &str,","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/cli/src/commands/app/create.rs#L224-L260","documentation":"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.","triggerScenarios":"Running `wasmer app create` (from package or template) targeting a directory (default: current directory) that already contains files, without --dir pointing elsewhere.","commonSituations":"Running the command inside an existing project folder or git repo; re-running create after a partial failure; forgetting the --dir flag.","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."],"exampleFix":"// before\n// wasmer app create --template my-template   (run in non-empty dir)\n// after\n// wasmer app create --template my-template --dir ./my-new-app","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nconst dir = args.dir ?? process.cwd();\nif (fs.readdirSync(dir).length > 0) {\n  throw new Error(`target directory ${dir} is not empty; use --dir`);\n}","typeGuard":"fn dir_is_empty(p: &Path) -> std::io::Result<bool> {\n    Ok(std::fs::read_dir(p)?.next().is_none())\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"directory is not empty\") => {\n        eprintln!(\"retrying with --dir ./new-app\");\n        // re-invoke command with --dir\n    }\n    other => other?,\n}","preventionTips":["Always scaffold into a fresh empty directory (use --dir).","Check directory contents before running app create.","Avoid running create commands inside existing project roots."],"tags":["wasmer","cli","filesystem","app-create"],"backgroundTag":"directory-not-empty","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}