DioxusLabs/dioxus · error
Failed to execute rustc command
Error message
Failed to execute rustc command
What it means
dx installs a rustc wrapper (rustcwrapper.rs) as RUSTC to intercept crate arguments for WASM splitting and hot-reload metadata; after capturing args it re-spawns the real `rustc` with inherited stdio. This expect fires when that rustc process cannot be spawned.
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_argsView on GitHub (pinned to 393d190a80)
Solutions
- Confirm `rustc --version` works in the environment dx runs in
- Restart the dx build after toolchain changes settle
- Pin one toolchain for the session (rust-toolchain.toml or rustup default) and avoid switching during builds
- Check the project directory was not deleted/moved mid-build (the wrapper re-runs with a recorded cwd)
Defensive patterns
Strategy: validation
Validate before calling
fn rustc_available() -> bool {
std::process::Command::new("rustc").arg("--version").output().is_ok()
} Prevention
- Pin the toolchain with rust-toolchain.toml for the duration of dx sessions
- Don't run rustup update or toolchain removals while dx serve is active
- If the project dir might move, restart builds rather than reusing running sessions
When it happens
Trigger: rustc disappearing or becoming non-executable while dx runs: toolchain uninstalled/switched mid-build, PATH changed by the build itself, or the recorded cwd no longer existing.
Common situations: Running rustup update or toolchain cleanup concurrently with dx serve; ephemeral CI containers pruning toolchains; Nix-style environments where the rustc path is transient.
Related errors
- Failed to run linker
- failed to execute process
- esbuild failed: {stderr}
- Failed to create args directory for rustc wrapper
- Failed to write rustc args to file
AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16).
Data as JSON: /api/errors/e57f2a97d04e43be.
Report an issue: GitHub.