{"record":{"id":"f0481c962a62a150","repo":"leptos-rs/leptos","slug":"failed-to-read-hash-file-f0481c","errorCode":null,"errorMessage":"failed to read hash file","messagePattern":"failed to read hash file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"meta/src/stylesheet.rs","lineNumber":67,"sourceCode":"    options: LeptosOptions,\n    /// An ID for the stylesheet.\n    #[prop(optional, into)]\n    id: Option<String>,\n    /// A base url, not including a trailing slash\n    #[prop(optional, into)]\n    root: Option<String>,\n) -> impl IntoView {\n    let mut css_file_name = options.output_name.to_string();\n    if options.hash_files {\n        let hash_path = std::env::current_exe()\n            .map(|path| {\n                path.parent().map(|p| p.to_path_buf()).unwrap_or_default()\n            })\n            .unwrap_or_default()\n            .join(options.hash_file.as_ref());\n        if hash_path.exists() {\n            let hashes = std::fs::read_to_string(&hash_path)\n                .expect(\"failed to read hash file\");\n            for line in hashes.lines() {\n                let line = line.trim();\n                if !line.is_empty() {\n                    if let Some((file, hash)) = line.split_once(':') {\n                        if file == \"css\" {\n                            css_file_name\n                                .push_str(&format!(\".{}\", hash.trim()));\n                        }\n                    }\n                }\n            }\n        }\n    }\n    css_file_name.push_str(\".css\");\n    let pkg_path = &options.site_pkg_dir;\n    let root = root.unwrap_or_default();\n\n    link()","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/meta/src/stylesheet.rs#L49-L85","documentation":"HashedStylesheet reads an optional hash file that maps asset names to content hashes (e.g. \"css:<hash>\") to locate the hashed CSS output. If the file exists at the configured path but cannot be read (permissions, race where it disappears, IO error), the expect panics with \"failed to read hash file\". The library treats an existing-but-unreadable hash file as an unrecoverable configuration error.","triggerScenarios":"options.hash_file is set, hash_path.exists() returns true, but std::fs::read_to_string fails — permission denied, file deleted between exists() check and read, path is a directory, or invalid UTF-8 content.","commonSituations":"Docker containers copying build artifacts with wrong ownership, CI caching a hash file that's later pruned, running the server as a non-root user without read access to target/ assets, or a stale hash_file option pointing at a removed intermediate file.","solutions":["Verify the hash file path in HashedStylesheet options points at a readable, UTF-8 text file produced by the asset build.","Check file permissions/ownership so the server process can read it (chmod/chown).","Remove the hash_file option or delete the stale file if you don't need hashed CSS lookup — the code skips reading when the file doesn't exist.","Re-run the CSS build pipeline (e.g. cargo-leptos style build) to regenerate the hash file before starting the server."],"exampleFix":"// before: stale path\nHashedStylesheet::new(options.hash_file(\"target/hash-file.txt\"), \"/pkg\")\n\n// after: ensure file is generated and readable, or omit\nHashedStylesheet::new(options, \"/pkg\") // with hash file regenerated by build step","handlingStrategy":"validation","validationCode":"let hash_path = compute_hash_path(options);\nif hash_path.exists() {\n    std::fs::read_to_string(&hash_path)\n        .map_err(|e| anyhow!(\"hash file unreadable: {e}\"))?;\n}","typeGuard":"fn hash_file_readable(path: &Path) -> bool {\n    path.is_file() && std::fs::read_to_string(path).is_ok()\n}","tryCatchPattern":null,"preventionTips":["Generate the hash file in the build pipeline before the server starts.","Ensure container/CI file ownership allows the server user to read build assets.","Remove or clear the hash_file option if you don't need hashed stylesheet lookup."],"tags":["rust","filesystem","leptos","assets","ssr"],"backgroundTag":"asset-hash-file-unreadable","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}