DioxusLabs/dioxus · error

failed to read input file

Error message

failed to read input file

What it means

The wasm-split CLI entry point reads the two wasm files passed as arguments (original and bindgened) with std::fs::read and expects success. A missing, unreadable, or mistyped path aborts with this panic before any splitting starts.

Source

Thrown at packages/wasm-split/wasm-split-cli/src/main.rs:42

    /// Validate the main module of a wasm module
    #[clap(name = "validate")]
    Validate(ValidateArgs),
}

#[derive(Parser)]
struct SplitArgs {
    /// The wasm module emitted by rustc
    original: PathBuf,

    /// The wasm module emitted by wasm-bindgen
    bindgened: PathBuf,

    /// The output *directory* to write the split wasm files to
    out_dir: PathBuf,
}

fn split(args: SplitArgs) {
    let original = std::fs::read(&args.original).expect("failed to read input file");
    let bindgened = std::fs::read(&args.bindgened).expect("failed to read input file");

    _ = std::fs::remove_dir_all(&args.out_dir);
    std::fs::create_dir_all(&args.out_dir).expect("failed to create output dir");

    tracing::info!("Building split module");

    let module = wasm_split_cli::Splitter::new(&original, &bindgened).unwrap();

    let mut chunks = module.emit().unwrap();

    // Write out the main module
    tracing::info!(
        "Writing main module to {}",
        args.out_dir.join("main.wasm").display()
    );
    std::fs::write(args.out_dir.join("main.wasm"), &chunks.main.bytes).unwrap();

View on GitHub (pinned to 393d190a80)

Solutions

  1. Check both paths exist before running (list the target directory)
  2. Use absolute paths or run the command from the directory the relative paths are based on
  3. Ensure the rustc and wasm-bindgen steps producing these files completed first
  4. Fix file permissions/ownership in CI
Defensive patterns

Strategy: validation

Validate before calling

use std::path::Path;
fn inputs_readable(paths: &[&Path]) -> bool {
    paths.iter().all(|p| p.is_file() && std::fs::metadata(p).is_ok())
}
assert!(inputs_readable(&[&args.original, &args.bindgened]));

Prevention

When it happens

Trigger: Invoking wasm-split-cli split with a wrong path, a file that hasn't been produced yet (the rustc/wasm-bindgen steps haven't run), permission problems, or relative paths resolved from the wrong working directory.

Common situations: Manual CLI invocation with typos or relative paths; CI steps racing ahead of the wasm-bindgen step; missing artifacts after a clean; running the CLI from a different directory than assumed.

Related errors


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