tauri-apps/tauri · error
Tauri "Isolation" Pattern only supports relative or absolute
Error message
Tauri "Isolation" Pattern only supports relative or absolute (`/`) paths.
What it means
Same Isolation Pattern inlining logic as html.rs, implemented in the alternate HTML processing module (html2.rs): script src paths are resolved against the dist directory and rooted paths are normalized by stripping '/'. The expect fires when strip_prefix("/") fails, i.e. the path is rooted without starting with '/': Windows drive letters or UNC paths.
Source
Thrown at crates/tauri-utils/src/html2.rs:152
///
/// # Stability
///
/// This dependency [`dom_query`] for [`Document`] might receive updates in minor releases.
#[cfg(feature = "isolation")]
pub fn inline_isolation(document: &Document, dir: &std::path::Path) {
let scripts = document.select("script[src]");
for script in scripts.nodes() {
let src = match script.attr("src") {
Some(s) => s.to_string(),
None => continue,
};
let mut path = std::path::PathBuf::from(src);
if path.has_root() {
path = path
.strip_prefix("/")
.expect("Tauri \"Isolation\" Pattern only supports relative or absolute (`/`) paths.")
.into();
}
let file = std::fs::read_to_string(dir.join(path)).expect("unable to find isolation file");
script.set_text(file);
script.remove_attr("src");
}
}
// TODO: Verify this, this is not found in the HTML spec, see https://github.com/tauri-apps/tauri/pull/14265#discussion_r2415396842
/// Normalize line endings in script content to match what the browser uses for CSP hashing.
///
/// According to the HTML spec, browsers normalize:
/// - `\r\n` → `\n`
/// - `\r` → `\n`
pub fn normalize_script_for_csp(input: &[u8]) -> Vec<u8> {
let mut output = Vec::with_capacity(input.len());View on GitHub (pinned to 56d19c39e4)
Solutions
- Use a src relative to the frontend dist directory.
- Or use a URL-absolute path starting with a single '/'.
- Remove any drive-letter or UNC path from script src attributes in the isolation HTML.
Example fix
<!-- before --> <script src="D:\build\isolation.js"></script> <!-- after --> <script src="/isolation.js"></script>
Defensive patterns
Strategy: validation
Validate before calling
fn is_supported_isolation_src(src: &str) -> bool {
let b = src.as_bytes();
!(src.starts_with("\\\\") || (b.len() >= 2 && b[1] == b':'))
} Prevention
- Use relative or single-leading-slash src values in the isolation HTML.
- Reject Windows absolute and UNC paths in code review of the isolation template.
When it happens
Trigger: Using the html2-based processing path with an isolation index.html containing <script src="C:\path\file.js"> or a UNC (\\server\share\file.js) src on Windows; Unix-style '/file.js' works.
Common situations: Windows development machines and CI; absolute local paths committed into the isolation template.
Related errors
- Tauri "Isolation" Pattern only supports relative or absolute
- unable to find isolation file
- unable to find isolation file
- failed to extract external binary filename
- failed to read binary path
AI-assisted analysis of tauri-apps/tauri@56d19c39e4 (2026-08-20).
Data as JSON: /api/errors/a2b9d1ae25f1699a.
Report an issue: GitHub.