{"record":{"id":"5b9db6aa5440ebe8","repo":"tauri-apps/tauri","slug":"unable-to-find-isolation-file-5b9db6","errorCode":null,"errorMessage":"unable to find isolation file","messagePattern":"unable to find isolation file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-utils/src/html2.rs","lineNumber":156,"sourceCode":"#[cfg(feature = \"isolation\")]\npub fn inline_isolation(document: &Document, dir: &std::path::Path) {\n  let scripts = document.select(\"script[src]\");\n\n  for script in scripts.nodes() {\n    let src = match script.attr(\"src\") {\n      Some(s) => s.to_string(),\n      None => continue,\n    };\n\n    let mut path = std::path::PathBuf::from(src);\n    if path.has_root() {\n      path = path\n        .strip_prefix(\"/\")\n        .expect(\"Tauri \\\"Isolation\\\" Pattern only supports relative or absolute (`/`) paths.\")\n        .into();\n    }\n\n    let file = std::fs::read_to_string(dir.join(path)).expect(\"unable to find isolation file\");\n\n    script.set_text(file);\n    script.remove_attr(\"src\");\n  }\n}\n\n// TODO: Verify this, this is not found in the HTML spec, see https://github.com/tauri-apps/tauri/pull/14265#discussion_r2415396842\n/// Normalize line endings in script content to match what the browser uses for CSP hashing.\n///\n/// According to the HTML spec, browsers normalize:\n/// - `\\r\\n` → `\\n`\n/// - `\\r`   → `\\n`\npub fn normalize_script_for_csp(input: &[u8]) -> Vec<u8> {\n  let mut output = Vec::with_capacity(input.len());\n\n  let mut i = 0;\n  while i < input.len() {\n    match input[i] {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/tauri-apps/tauri/blob/56d19c39e457b528433dc546106cd0bff4066bc2/crates/tauri-utils/src/html2.rs#L138-L174","documentation":"html2.rs variant of the Isolation Pattern inliner: after normalizing a script's src, Tauri reads dir.join(path) and inlines the file contents into the HTML. The expect fires when the read fails: the file does not exist at the resolved path, a parent directory is missing, permission denied, or content is not valid UTF-8.","triggerScenarios":"A script src that resolves to a nonexistent file under the frontend dist directory: wrong ../ depth, typo, file not emitted into dist by the frontend build, or a frontendDist config mismatch.","commonSituations":"Frontend build not copying the isolation script to dist; path levels off after moving the HTML file; distDir changed without updating script paths.","solutions":["Confirm the file exists at <frontendDist>/<src> at build time.","Point src at a file the frontend build emits into dist.","Run any script generator before tauri dev / tauri build.","Align tauri.conf.json app.frontendDist with the folder that contains the file."],"exampleFix":"<!-- before -->\n<script src=\"isolation.js\"></script> <!-- dist only contains assets/isolation.js -->\n\n<!-- after -->\n<script src=\"assets/isolation.js\"></script>","handlingStrategy":"validation","validationCode":"let dist = std::path::Path::new(\"../path/to/dist\");\nfor src in collect_script_srcs(\"isolation/index.html\") {\n    let p = dist.join(src.trim_start_matches('/'));\n    assert!(p.is_file(), \"isolation script missing: {}\", p.display());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify each referenced script exists in the dist output before building.","Automate the existence check in the frontend build's post-build step."],"tags":["tauri","isolation-pattern","file-not-found","html"],"backgroundTag":"file-not-found","analyzedSha":"56d19c39e457b528433dc546106cd0bff4066bc2","analyzedAt":"2026-08-20T13:59:20.734Z","contentChangedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}