{"record":{"id":"1bcf1971c81354db","repo":"wasmerio/wasmer","slug":"error-1bcf19","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/cli/src/commands/init.rs","lineNumber":219,"sourceCode":"                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)> + '_ {\n        include.iter().map(|path| {","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/cli/src/commands/init.rs#L201-L237","documentation":"Same code path as the previous error in `wasmer init`'s `target_file`: when a target directory `Some(s)` is supplied and `create_dir_all` fails, the CLI attaches the directory path itself as the anyhow context, so the reported message is just the path (`{}` for `s.display()`). It is the contextual layer over the mkdir OS error, shown as `path: <os error>`.","triggerScenarios":"Running `wasmer init <dir>` where `std::fs::create_dir_all(s)` fails for the displayed path: parent not writable, a path component is an existing regular file, invalid path characters, or read-only filesystem.","commonSituations":"Same as the underlying mkdir failure — bad target paths, permission-restricted locations, file-vs-directory conflicts, read-only CI containers.","solutions":["Inspect the path shown in the error and confirm each component is valid and doesn't collide with an existing file.","Ensure the nearest existing ancestor of the path is writable by the current user.","Choose a different target directory under your home or project root.","Retry after fixing permissions, or run `wasmer init` without a target to use the current directory."],"exampleFix":"// before\nwasmer init /etc/wasmer-app  // /etc/wasmer-app: Permission denied\n// after\nwasmer init ~/wasmer-app","handlingStrategy":"validation","validationCode":"fn validate_target(p: &Path) -> Result<(), String> {\n    let mut anc = p.ancestors().skip(1);\n    while let Some(a) = anc.next() {\n        if a.exists() && !a.is_dir() {\n            return Err(format!(\"{} exists and is not a directory\", a.display()));\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match init_in(dir).await {\n    Err(e) => {\n        // message is the path with the OS error as source\n        eprintln!(\"Failed creating target {}: {e}\", dir.display());\n    }\n    Ok(v) => v,\n}","preventionTips":["Check each path component of the target for file-vs-directory conflicts.","Fix ancestor permissions before scaffolding into nested paths.","Prefer simple relative paths from your project root."],"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"}