cloudflare/quiche · error
Error creating file for
Error message
Error creating file for {url}, attempted path was {path}: {e} What it means
make_resource_writer panics when std::fs::File::create fails for the file that will store the response body of a downloaded URL. The panic includes the URL, the attempted path, and the underlying io::Error. Failure is typically due to filesystem permissions, a missing parent directory, or the path being a directory.
Solutions
- Create the target directory first (mkdir -p) and verify write permissions.
- Check the 'attempted path was' message for a wrong or malformed path.
- Verify the filesystem is not read-only or full.
- Prefer running the client from a directory you own if relative paths are used.
Example fix
// before (directory does not exist) quiche-client --dump-dir /out https://example.org // after mkdir -p /out && quiche-client --dump-dir /out https://example.org
Defensive patterns
Strategy: validation
Validate before calling
let dir = std::path::Path::new(&out_dir);
assert!(dir.is_dir(), "output dir missing: {}", out_dir);
assert!(!dir.is_file(), "output path is a file: {}");
let probe = dir.join(".write_test");
std::fs::File::create(&probe).expect("output dir not writable");
let _ = std::fs::remove_file(&probe); Try / catch
// Since the app panics, isolate it: run in a subprocess and inspect stderr
let out = std::process::Command::new("quiche-client")
.args(["--dump-dir", &out_dir, url])
.output()
.expect("spawn failed");
if !out.status.success() {
eprintln!("client failed: {}", String::from_utf8_lossy(&out.stderr));
} Prevention
- Always create the dump directory before running the client.
- Run with write permissions on the target volume; avoid read-only containers.
- Monitor free disk space for large downloads.
When it happens
Trigger: Running quiche-client with a dump/save option where the derived output path (including the '.N' dedup suffix) cannot be created: parent directory missing, read-only filesystem, or permission denied.
Common situations: Saving responses into a directory that doesn't exist or isn't writable; running in a container with a read-only volume; disk full.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
AI-assisted analysis of cloudflare/quiche@9f96daa2c2 (2026-09-08).
Data as JSON: /api/errors/2f9c9269eb3c1fc5.
Report an issue: GitHub.
Appendix: source
Thrown at apps/src/common.rs:128
/// any value "N" greater than 1, will cause ".N" to be appended to the
/// filename.
fn make_resource_writer(
url: &url::Url, target_path: &Option<String>, cardinal: u64,
) -> Option<std::io::BufWriter<std::fs::File>> {
if let Some(tp) = target_path {
let resource =
url.path_segments().map(|c| c.collect::<Vec<_>>()).unwrap();
let mut path = format!("{}/{}", tp, resource.iter().last().unwrap());
if cardinal > 1 {
path = format!("{path}.{cardinal}");
}
match std::fs::File::create(&path) {
Ok(f) => return Some(std::io::BufWriter::new(f)),
Err(e) => panic!(
"Error creating file for {url}, attempted path was {path}: {e}"
),
}
}
None
}
fn autoindex(path: path::PathBuf, index: &str) -> path::PathBuf {
if let Some(path_str) = path.to_str() {
if path_str.ends_with('/') {
let path_str = format!("{path_str}{index}");
return path::PathBuf::from(&path_str);
}
}
path
}View on GitHub (pinned to 9f96daa2c2)