AlexsJones/llmfit · error

failed to write generated web_assets.rs

Error message

failed to write generated web_assets.rs

What it means

The final step of llmfit-tui/build.rs writes the generated web_assets.rs into OUT_DIR with fs::write(...).expect("failed to write generated web_assets.rs"). The generation itself cannot fail; the write fails only at the filesystem level — OUT_DIR removed mid-build, a read-only or full disk, sandbox/permission denials, or path-length limits on Windows.

Source

Thrown at llmfit-tui/build.rs:30

    let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR"));
    let out_file = out_dir.join("web_assets.rs");

    let generated = if dist_dir.exists() {
        let mut files = Vec::new();
        collect_files(&dist_dir, &mut files);
        files.sort();
        for file in &files {
            println!("cargo:rerun-if-changed={}", file.display());
        }
        generate_assets_from_dist(&dist_dir, &files)
    } else {
        println!(
            "cargo:warning=llmfit-web/dist not found. Falling back to placeholder embedded dashboard. Run `npm ci && npm run build` in llmfit-web."
        );
        generate_fallback_assets()
    };

    fs::write(&out_file, generated).expect("failed to write generated web_assets.rs");
}

fn collect_files(dir: &Path, files: &mut Vec<PathBuf>) {
    let entries = fs::read_dir(dir).unwrap_or_else(|_| panic!("failed to read {}", dir.display()));

    for entry in entries {
        let entry = entry.expect("invalid dir entry");
        let path = entry.path();
        if path.is_dir() {
            collect_files(&path, files);
        } else {
            files.push(path);
        }
    }
}

fn generate_assets_from_dist(dist_dir: &Path, files: &[PathBuf]) -> String {
    let mut output = String::new();

View on GitHub (pinned to acc7e40c3a)

Solutions

  1. Free space or raise the quota on the volume holding target/, then rebuild
  2. Avoid concurrent cargo clean/build over the same target directory; use separate target dirs (CARGO_TARGET_DIR) for parallel jobs
  3. Check permissions of target/debug/build/llmfit-*/out/ and remount/adjust the sandbox so OUT_DIR is writable
Defensive patterns

Strategy: retry

Validate before calling

# shell pre-flight before cargo build
out_dir=$(ls -d target/debug/build/llmfit-*/out 2>/dev/null | head -1)
if [ -n "$out_dir" ] && ! touch "$out_dir/.probe" 2>/dev/null; then
  echo "OUT_DIR not writable — fix permissions/disk" >&2; exit 1
fi
df -h . | awk 'NR==2 && $5+0 > 95 { print "disk nearly full"; exit 1 }'

Prevention

When it happens

Trigger: A concurrent `cargo clean` deleting target/ while a build is in the write phase; a full disk or quota on the build volume; container/CI sandboxes mounting OUT_DIR read-only; antivirus locking the freshly created file on Windows.

Common situations: Disk-space exhaustion on CI runners with large embedded asset output; parallel cargo invocations racing over the same target dir; macOS/Windows security software interfering with generated files.

Related errors


AI-assisted analysis of AlexsJones/llmfit@acc7e40c3a (2026-08-17). Data as JSON: /api/errors/ab84ef26c09faa2f. Report an issue: GitHub.