DioxusLabs/dioxus · error

Failed to execute rustc command

Error message

Failed to execute rustc command

What it means

`run_rustc` spawns the real rustc as a subprocess with inherited output; this panic fires if spawning fails (rustc not found on PATH, permission denied, etc.). It is a process-launch failure, not a compilation error — compile errors pass through rustc's own output.

Solutions

  1. Check that the rustc binary referenced by DX_RUSTC exists and is executable, and inspect the wrapped command arguments for errors.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/cli/src/rustcwrapper.rs:94 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/e57f2a97d04e43be. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/rustcwrapper.rs:94

        return crate::link::LinkAction::from_env()
            .expect("Linker action not found")
            .run_link();
    }

    // Run the actual rustc command.
    // We want all stdout/stderr to be inherited, so the user sees the compiler output.
    let mut cmd = std::process::Command::new("rustc");

    // The first argument in `captured_args` is the rustc path, which we need to skip
    // when passing arguments to the `rustc` command we are spawning.
    cmd.args(captured_args.iter().skip(1));
    cmd.envs(rustc_args.envs);
    cmd.current_dir(rustc_args.cwd);
    cmd.stdout(std::process::Stdio::inherit());
    cmd.stderr(std::process::Stdio::inherit());

    // Spawn the process and propagate its exit code.
    let status = cmd.status().expect("Failed to execute rustc command");
    std::process::exit(status.code().unwrap_or(1)); // Exit with 1 if process was killed by signal
}

fn write_rustc_args(args_dir: &PathBuf, rustc_args: &RustcArgs) {
    // Extract the crate name from the args to use as the filename.
    // Skip non-sensical args when a build is completely fresh (rustc is invoked with --crate-name ___)
    let crate_name = rustc_args
        .args
        .iter()
        .skip_while(|arg| *arg != "--crate-name")
        .nth(1);

    if let Some(crate_name) = crate_name {
        if crate_name != "___" {
            std::fs::create_dir_all(args_dir)
                .expect("Failed to create args directory for rustc wrapper");

            let crate_type = rustc_args

View on GitHub (pinned to 24f6a829df)