{"record":{"id":"1e7549c52a0025bf","repo":"wasmerio/wasmer","slug":"e","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/cli/src/commands/init.rs","lineNumber":218,"sourceCode":"            None => {\n                let current_dir = std::env::current_dir()?;\n                let package_name = self\n                    .package_name\n                    .clone()\n                    .or_else(|| {\n                        current_dir\n                            .canonicalize()\n                            .ok()?\n                            .file_stem()\n                            .and_then(|s| s.to_str())\n                            .map(|s| s.to_string())\n                    })\n                    .ok_or_else(|| anyhow::anyhow!(\"no current dir name\"))?;\n                Ok((package_name, current_dir.join(WASMER_TOML_NAME)))\n            }\n            Some(s) => {\n                std::fs::create_dir_all(s)\n                    .map_err(|e| anyhow::anyhow!(\"{e}\"))\n                    .with_context(|| anyhow::anyhow!(\"{}\", s.display()))?;\n                let package_name = self\n                    .package_name\n                    .clone()\n                    .or_else(|| {\n                        s.canonicalize()\n                            .ok()?\n                            .file_stem()\n                            .and_then(|s| s.to_str())\n                            .map(|s| s.to_string())\n                    })\n                    .ok_or_else(|| anyhow::anyhow!(\"no dir name\"))?;\n                Ok((package_name, s.join(WASMER_TOML_NAME)))\n            }\n        }\n    }\n\n    fn get_filesystem_mapping(include: &[String]) -> impl Iterator<Item = (String, PathBuf)> + '_ {","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/cli/src/commands/init.rs#L200-L236","documentation":"In `wasmer init`'s `target_file`, when a target directory `Some(s)` is provided, `std::fs::create_dir_all(s)` creates it. The raw OS error is mapped with `anyhow::anyhow!(\"{e}\")` and then wrapped with context of the directory path, so this bare `{e}` message is the underlying mkdir failure (e.g. permission denied) displayed alongside the directory context.","triggerScenarios":"Running `wasmer init <dir>` where creating `<dir>` (and any missing parents) fails: permission denied on the parent, the path exists as a non-directory file, the filesystem is read-only, or a path component is invalid.","commonSituations":"Initializing into a root-owned or read-only location; passing a path where an existing file occupies a component; typo'd absolute paths; containers with restricted write mounts.","solutions":["Check permissions on the target's parent and `chmod`/`chown` or choose a writable directory.","Verify no existing file conflicts with the target path (`ls -la <path>`) and remove/rename it.","Run with elevated privileges only if appropriate, or init into a user-writable directory instead.","If the filesystem is read-only, select a writable mount or remount read-write."],"exampleFix":"// before\nwasmer init /root/myapp  // Permission denied (os error 13)\n// after\nwasmer init ~/projects/myapp","handlingStrategy":"validation","validationCode":"fn can_create_dir(target: &Path) -> bool {\n    if target.is_dir() {\n        return true;\n    }\n    target.parent()\n        .map(|p| p.is_dir() && std::fs::metadata(p)\n            .map(|m| !m.permissions().readonly())\n            .unwrap_or(false))\n        .unwrap_or(false)\n}\nassert!(can_create_dir(Path::new(\"~/projects/myapp\")), \"target dir not creatable\");","typeGuard":null,"tryCatchPattern":"match init_in(dir).await {\n    Err(e) if e.to_string().contains(\"os error 13\") || e.to_string().contains(\"Permission denied\") => {\n        eprintln!(\"Cannot create {dir:?}: check permissions or pick a writable path\");\n    }\n    other => other?,\n}","preventionTips":["Create init targets under user-writable roots (home, project dir).","Ensure no existing file occupies the target path (`ls -la` first).","Avoid read-only mounts and root-owned locations for scaffolding."],"tags":["cli","filesystem","package-init"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}