DioxusLabs/dioxus · error

Failed to create args directory for rustc wrapper

Error message

Failed to create args directory for rustc wrapper

What it means

`write_rustc_args` creates the args directory (provided via `DX_RUSTC`) before writing per-crate arg files; this panic fires if directory creation fails due to permissions, an invalid path, or the path existing as a file.

Solutions

  1. Check permissions and available disk space for the directory the rustc wrapper uses to store args; create the parent directory manually if needed.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/cli/src/rustcwrapper.rs:110 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/7ef6122f8350778e. Report an issue: GitHub.

Appendix: source

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

    // 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
                .args
                .iter()
                .skip_while(|arg| *arg != "--crate-type")
                .nth(1)
                .map(|s| s.as_str());

            let serialized_args =
                serde_json::to_string(rustc_args).expect("Failed to serialize rustc args");

            // Write args with an explicit target suffix: {crate_name}.lib.json or
            // {crate_name}.bin.json. This avoids the ambiguity of a bare {crate_name}.json
            // and ensures lib+bin crates don't overwrite each other.
            let suffix = match crate_type {
                Some("lib" | "rlib") => "lib",
                Some("bin") => "bin",
                _ => "bin", // proc-macro, cdylib, etc. — treat as bin

View on GitHub (pinned to 24f6a829df)