DioxusLabs/dioxus · error
input_path should be valid utf8
Error message
input_path should be valid utf8
What it means
Before invoking wasm-bindgen, dx stringifies the output directory with Path::to_str(); on this platform paths can contain non-UTF-8 bytes, to_str() returns None, and the expect panics. The message says input_path but line 147 converts out_dir - a copy-paste in the panic text.
Source
Thrown at packages/cli/src/wasm_bindgen.rs:147
args.push("--remove-producers-section");
}
if self.keep_lld_exports {
args.push("--keep-lld-exports");
}
// Out name
args.push("--out-name");
args.push(&self.out_name);
// wbg generates typescript bindnings by default - we don't want those
args.push("--no-typescript");
// Out dir
let out_dir = self
.out_dir
.to_str()
.expect("input_path should be valid utf8");
args.push("--out-dir");
args.push(out_dir);
// Input path
let input_path = self
.input_path
.to_str()
.expect("input_path should be valid utf8");
args.push(input_path);
tracing::debug!("wasm-bindgen: {:#?}", args);
// Run bindgen
let output = Command::new(binary).args(args).output().await?;
// Check for errors
if !output.stderr.is_empty() {View on GitHub (pinned to 393d190a80)
Solutions
- Move or clone the project to a purely ASCII, UTF-8-safe path
- Point CARGO_TARGET_DIR at a short ASCII path (e.g. /tmp/dx-target or C:\\dx\\target)
- Rename the offending parent directory so the full path becomes valid UTF-8
Defensive patterns
Strategy: validation
Validate before calling
fn assert_utf8_path(p: &std::path::Path) -> anyhow::Result<&str> {
p.to_str().ok_or_else(|| anyhow::anyhow!("path is not valid UTF-8: {:?}", p))
} Type guard
fn is_utf8_path(p: &std::path::Path) -> bool { p.to_str().is_some() } Prevention
- Keep projects and build outputs under pure-ASCII paths on Windows/macOS
- Set CARGO_TARGET_DIR to a short ASCII path when usernames contain non-ASCII characters
- After moving/cloning projects, verify paths still decode as UTF-8
When it happens
Trigger: dx serve/dx build for web where the target/output directory path contains bytes invalid as UTF-8 - typically Windows or macOS folders or usernames with legacy encodings (latin-1, shift-jis).
Common situations: Non-ASCII usernames with broken normalization; projects moved from old systems with differently encoded directory names; mounted volumes exposing byte-encoded names.
Related errors
- Failed to convert wasm bindgen output path to string
- expected URL to be UTF-8 encoded
- Failed to read index.html from public directory
- failed to expand ifunc table
- Could not find export
AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16).
Data as JSON: /api/errors/ae9cb002ca1750db.
Report an issue: GitHub.