wasmerio/wasmer · error
{}
Error message
{} What it means
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>`.
Source
Thrown at lib/cli/src/commands/init.rs:219
let current_dir = std::env::current_dir()?;
let package_name = self
.package_name
.clone()
.or_else(|| {
current_dir
.canonicalize()
.ok()?
.file_stem()
.and_then(|s| s.to_str())
.map(|s| s.to_string())
})
.ok_or_else(|| anyhow::anyhow!("no current dir name"))?;
Ok((package_name, current_dir.join(WASMER_TOML_NAME)))
}
Some(s) => {
std::fs::create_dir_all(s)
.map_err(|e| anyhow::anyhow!("{e}"))
.with_context(|| anyhow::anyhow!("{}", s.display()))?;
let package_name = self
.package_name
.clone()
.or_else(|| {
s.canonicalize()
.ok()?
.file_stem()
.and_then(|s| s.to_str())
.map(|s| s.to_string())
})
.ok_or_else(|| anyhow::anyhow!("no dir name"))?;
Ok((package_name, s.join(WASMER_TOML_NAME)))
}
}
}
fn get_filesystem_mapping(include: &[String]) -> impl Iterator<Item = (String, PathBuf)> + '_ {
include.iter().map(|path| {View on GitHub (pinned to 8c4b9ee9d3)
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.
Example fix
// before wasmer init /etc/wasmer-app // /etc/wasmer-app: Permission denied // after wasmer init ~/wasmer-app
Defensive patterns
Strategy: validation
Validate before calling
fn validate_target(p: &Path) -> Result<(), String> {
let mut anc = p.ancestors().skip(1);
while let Some(a) = anc.next() {
if a.exists() && !a.is_dir() {
return Err(format!("{} exists and is not a directory", a.display()));
}
}
Ok(())
} Try / catch
match init_in(dir).await {
Err(e) => {
// message is the path with the OS error as source
eprintln!("Failed creating target {}: {e}", dir.display());
}
Ok(v) => v,
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Same as the underlying mkdir failure — bad target paths, permission-restricted locations, file-vs-directory conflicts, read-only CI containers.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- no current dir name
- {e}
- no dir name
- Stopping as the directory is not empty
- Cannot pre-open the current directory twice: '--volume=.' mu
AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01).
Data as JSON: /api/errors/1bcf1971c81354db.
Report an issue: GitHub.