DioxusLabs/dioxus · error · anyhow::Error

Failed to convert wasm bindgen output path to string

Error message

Failed to convert wasm bindgen output path to string

What it means

register_asset converts the asset path to a &str before handing it to manganis' create_bundled_asset; paths containing non-UTF-8 bytes fail Path::to_str() and bail with this (historically worded) message about the wasm-bindgen output path, since the same code path handles wasm-bindgen artifacts. No asset processing is attempted.

Source

Thrown at packages/cli/src/opt/mod.rs:52

}

impl AppManifest {
    pub fn new() -> Self {
        Self {
            cli_version: crate::VERSION.to_string(),
            android_artifacts: Default::default(),
            swift_sources: Default::default(),
            assets: Default::default(),
        }
    }

    /// Manually add an asset to the manifest
    pub fn register_asset(
        &mut self,
        asset_path: &Path,
        options: manganis::AssetOptions,
    ) -> anyhow::Result<BundledAsset> {
        let output_path_str = asset_path.to_str().ok_or(anyhow::anyhow!(
            "Failed to convert wasm bindgen output path to string"
        ))?;

        let mut bundled_asset =
            manganis::macro_helpers::create_bundled_asset(output_path_str, options);
        add_hash_to_asset(&mut bundled_asset);

        self.assets
            .entry(asset_path.to_path_buf())
            .or_default()
            .insert(bundled_asset);

        Ok(bundled_asset)
    }

    /// Insert an existing bundled asset to the manifest
    pub fn insert_asset(&mut self, asset: BundledAsset) {
        let asset_path = asset.absolute_source_path();

View on GitHub (pinned to 393d190a80)

Solutions

  1. Move or clone the project so every path component is valid UTF-8 (ASCII is safest)
  2. Rename the offending directory, or set a UTF-8 locale for the build environment
  3. Check with: cargo metadata style inspection or 'ls | iconv -f utf-8 -t utf-8' to find undecodable components
Defensive patterns

Strategy: validation

Validate before calling

// Assert early in build scripts
fn assert_utf8_paths(paths: &[std::path::PathBuf]) {
    for p in paths {
        assert!(p.to_str().is_some(), "non-UTF-8 path component in {p:?}");
    }
}

Type guard

fn is_utf8_path(p: &std::path::Path) -> bool { p.to_str().is_some() }

Prevention

When it happens

Trigger: An asset or wasm-bindgen output whose absolute path contains non-UTF-8 bytes — typically a username or directory created under a non-UTF-8 locale on Linux/macOS — registered during a dx build.

Common situations: Building in a home directory with legacy-encoding characters; project paths copied from other systems with mis-decoded components; CI runners provisioned with odd locale settings.

Related errors


AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16). Data as JSON: /api/errors/ea50de1f22c1ca3c. Report an issue: GitHub.