wasmerio/wasmer · error
{e}
Error message
{e} What it means
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.
Source
Thrown at lib/cli/src/commands/init.rs:218
None => {
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)> + '_ {View on GitHub (pinned to 8c4b9ee9d3)
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.
Example fix
// before wasmer init /root/myapp // Permission denied (os error 13) // after wasmer init ~/projects/myapp
Defensive patterns
Strategy: validation
Validate before calling
fn can_create_dir(target: &Path) -> bool {
if target.is_dir() {
return true;
}
target.parent()
.map(|p| p.is_dir() && std::fs::metadata(p)
.map(|m| !m.permissions().readonly())
.unwrap_or(false))
.unwrap_or(false)
}
assert!(can_create_dir(Path::new("~/projects/myapp")), "target dir not creatable"); Try / catch
match init_in(dir).await {
Err(e) if e.to_string().contains("os error 13") || e.to_string().contains("Permission denied") => {
eprintln!("Cannot create {dir:?}: check permissions or pick a writable path");
}
other => other?,
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
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
- {}
- 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/1e7549c52a0025bf.
Report an issue: GitHub.