{"record":{"id":"aefb618fcd3f3298","repo":"tracel-ai/burn","slug":"failed-to-create-cache-file-aefb61","errorCode":null,"errorMessage":"Failed to create cache file","messagePattern":"Failed to create cache file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-train/src/metric/vision/lpips/weights.rs","lineNumber":62,"sourceCode":"/// Get the cache directory for LPIPS weights.\nfn get_cache_dir() -> PathBuf {\n    let cache_dir = dirs::cache_dir()\n        .expect(\"Could not get cache directory\")\n        .join(\"burn-dataset\")\n        .join(\"lpips\");\n\n    if !cache_dir.exists() {\n        create_dir_all(&cache_dir).expect(\"Failed to create cache directory\");\n    }\n\n    cache_dir\n}\n\n/// Download file if not cached and return the cache path.\nfn download_if_needed(url: &str, cache_path: &PathBuf, message: &str) {\n    if !cache_path.exists() {\n        let bytes = download_file_as_bytes(url, message);\n        let mut file = File::create(cache_path).expect(\"Failed to create cache file\");\n        file.write_all(&bytes).expect(\"Failed to write weights\");\n    }\n}\n\n/// Download and load pretrained weights into an LPIPS module.\n///\n/// This loads both:\n/// 1. ImageNet pretrained backbone weights (VGG16/AlexNet/SqueezeNet)\n/// 2. LPIPS trained linear layer weights\n///\n/// Weights are cached in the user's cache directory to avoid re-downloading.\n///\n/// # Arguments\n///\n/// * `lpips` - The LPIPS module to load weights into.\n/// * `net` - The network type (determines which weights to download).\n///\n/// # Returns","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-train/src/metric/vision/lpips/weights.rs#L44-L80","documentation":"I/O guard in the LPIPS weights downloader: creating the cache file to store downloaded LPIPS backbone weights failed, so the download path panics rather than run the metric without its pretrained weights.","triggerScenarios":"Thrown at crates/burn-train/src/metric/vision/lpips/weights.rs:62 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify disk space and permissions in the lpips cache directory","Ensure the cache path points to a writable location","Pre-download and place the weights file at the cache path"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}