DioxusLabs/dioxus · error
Failed to write rustc args to file
Error message
Failed to write rustc args to file
What it means
Final step of the rustc wrapper's arg capture: writing the serialized args to {crate_name}.{lib|bin}.json fails at the fs::write level after the directory already exists - disk full, permission denied on the file, or an OS-level path problem.
Source
Thrown at packages/cli/src/rustcwrapper.rs:135
.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
};
std::fs::write(
args_dir.join(format!("{crate_name}.{suffix}.json")),
&serialized_args,
)
.expect("Failed to write rustc args to file");
}
}
}
/// Check if the arguments indicate a linking step, including those in command files.
fn has_linking_args() -> bool {
for arg in std::env::args() {
// Direct check for linker-like arguments
if arg.ends_with(".o") || arg == "-flavor" {
return true;
}
// Check inside command files
if let Some(path_str) = arg.strip_prefix('@') {
if let Ok(file_binary) = std::fs::read(path_str) {
// Handle both UTF-8 and UTF-16LE encodings for response files.
let content = String::from_utf8(file_binary.clone()).unwrap_or_else(|_| {
let binary_u16le: Vec<u16> = file_binaryView on GitHub (pinned to 393d190a80)
Solutions
- Free disk space or raise the quota, then rebuild
- Delete the dioxus rustc-args directory under target and retry so files are recreated cleanly
- Set CARGO_TARGET_DIR to a short path (e.g. C:\\dx\\target) to dodge Windows path-length limits
- Don't share one target dir between dx instances running as different users
Defensive patterns
Strategy: validation
Prevention
- Monitor disk space during long dx sessions; the wrapper writes one JSON per crate
- Use a short CARGO_TARGET_DIR on Windows to avoid path-length failures
- Don't share one target dir between dx instances running as different users
When it happens
Trigger: ENOSPC/quota exhaustion during a dx build; a same-named args file owned by another user from a concurrent build; path-length limits on Windows with deep target dirs and long crate names.
Common situations: CI runners with small ephemeral disks; two dx builds sharing one target dir under different users; very deep project paths on Windows.
Related errors
- Failed to create args directory for rustc wrapper
- failed to read input file
- failed to write js module
- esbuild failed: {stderr}
- Failed to run linker
AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16).
Data as JSON: /api/errors/665b011910203da4.
Report an issue: GitHub.