{"record":{"id":"8ad025b7a459e53a","repo":"tracel-ai/burn","slug":"failed-to-create-cache-directory-8ad025","errorCode":null,"errorMessage":"Failed to create cache directory","messagePattern":"Failed to create cache directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-train/src/metric/vision/lpips/weights.rs","lineNumber":52,"sourceCode":"\n/// Get the download URL for backbone ImageNet weights.\npub fn get_backbone_weights_url(net: LpipsNet) -> &'static str {\n    match net {\n        LpipsNet::Vgg => VGG16_IMAGENET_URL,\n        LpipsNet::Alex => ALEXNET_IMAGENET_URL,\n        LpipsNet::Squeeze => SQUEEZENET_IMAGENET_URL,\n    }\n}\n\n/// 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)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-train/src/metric/vision/lpips/weights.rs#L34-L70","documentation":"I/O guard in the LPIPS weights loader: creating the burn-dataset/lpips cache directory failed (permissions or path issues), so obtaining the cache dir panics instead of proceeding to download weights.","triggerScenarios":"Thrown at crates/burn-train/src/metric/vision/lpips/weights.rs:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check write permissions on the parent cache directory","Ensure no file exists at the directory path blocking creation","Create the directory manually with correct ownership"],"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"}