{"record":{"id":"a2b9d1ae25f1699a","repo":"tauri-apps/tauri","slug":"tauri-isolation-pattern-only-supports-relative-o-a2b9d1","errorCode":null,"errorMessage":"Tauri \"Isolation\" Pattern only supports relative or absolute (`/`) paths.","messagePattern":"Tauri \"Isolation\" Pattern only supports relative or absolute \\(`/`\\) paths\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-utils/src/html2.rs","lineNumber":152,"sourceCode":"///\n/// # Stability\n///\n/// This dependency [`dom_query`] for [`Document`] might receive updates in minor releases.\n#[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());","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-utils/src/html2.rs#L134-L170","documentation":"In the Tauri build-time HTML inlining, `inline_isolation` reads the isolation pattern's script file and embeds its content into the HTML. The `strip_prefix(\"/\")` is wrapped in `expect` with this message, so it panics when the `src` path cannot have its leading `/` stripped — i.e. it is not a relative path and not a plain absolute `/`-rooted path (on Windows this includes drive-letter or UNC paths). The library only supports paths relative to the isolation dir or absolute paths rooted at `/`.","triggerScenarios":"Calling `inline_isolation` (via the HTML inliner during `tauri build`/`tauri dev` codegen) where the `<script src>` for the isolation pattern resolves to a `PathBuf` with a root that is not just `/` — e.g. `C:\\isolation\\index.js` or `\\\\server\\share\\x.js` on Windows, or any path whose `has_root()` is true but `strip_prefix(\"/\")` fails.","commonSituations":"Windows developers configuring `app.security.pattern` isolation with an absolute Windows path; CI machines where an env var injects a drive-lettered path; paths built with `PathBuf::from(\"C:...\")` instead of relative paths in tauri.conf.json.","solutions":["Use a path relative to the isolation directory (e.g. `isolation.js` or `../isolation/index.js`) instead of an absolute OS path","On Windows, express the path as a `/`-rooted absolute path such as `/isolation/index.js` rather than `C:\\...`","Avoid UNC paths (`\\\\...`) for the isolation script source","If you control the input, normalize/strip the drive or prefix before it reaches the inliner"],"exampleFix":"// before\n<script src=\"C:\\isolation\\index.js\"></script>\n// after\n<script src=\"/isolation/index.js\"></script>","handlingStrategy":"validation","validationCode":"let path = std::path::PathBuf::from(src);\nif path.has_root() && !(path.starts_with(\"/\") && path.strip_prefix(\"/\").is_ok()) {\n  panic!(\"isolation src must be relative or `/`-rooted: {}\", src);\n}","typeGuard":"fn is_supported_isolation_path(src: &str) -> bool {\n  let p = std::path::PathBuf::from(src);\n  !p.has_root() || p.strip_prefix(\"/\").is_ok()\n}","tryCatchPattern":null,"preventionTips":["Always configure isolation script paths relative to the isolation dir","Avoid drive-letter and UNC paths on Windows; use `/`-rooted paths","Test `tauri build` on Windows early when using the isolation pattern"],"tags":["path-handling","build-time","panic","windows","tauri"],"backgroundTag":"invalid-argument-format","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}