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

Thrown while Tauri processes the index.html used by the Isolation Pattern. Every <script src=...> in that file is resolved against the app's dist directory: rooted paths are normalized by stripping the leading '/'. The expect fires when strip_prefix("/") fails, i.e. the path is rooted but does not start with '/': Windows drive letters (C:\...) or UNC paths (\\server\share\...).

Source

Thrown at crates/tauri-utils/src/html.rs:272

/// is secure.
pub fn inline_isolation(document: &NodeRef, dir: &Path) {
  for script in document
    .select("script[src]")
    .expect("unable to parse document for scripts")
  {
    let src = {
      let attributes = script.attributes.borrow();
      attributes
        .get(LocalName::from("src"))
        .expect("script with src attribute has no src value")
        .to_string()
    };

    let mut 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.as_node().append(NodeRef::new_text(file));

    let mut attributes = script.attributes.borrow_mut();
    attributes.remove(LocalName::from("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> {

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Change the script src in the isolation HTML to a path relative to the frontend dist directory (src="isolation.js" or src="assets/isolation.js").
  2. If it must be absolute, use a URL-style path starting with a single '/' (src="/isolation.js").
  3. Never use drive letters (C:\) or UNC (\\server\share) in script src attributes of the isolation index.html.

Example fix

<!-- before -->
<script src="C:\www\isolate.js"></script>

<!-- after -->
<script src="isolate.js"></script>
Defensive patterns

Strategy: validation

Validate before calling

// before building, lint the isolation index.html script srcs
fn is_supported_isolation_src(src: &str) -> bool {
    let b = src.as_bytes();
    !(src.starts_with("\\\\") || (b.len() >= 2 && b[1] == b':'))
}
for src in collect_script_srcs("isolation/index.html") {
    assert!(is_supported_isolation_src(src), "unsupported script src: {src}");
}

Prevention

When it happens

Trigger: Enabling the isolation pattern (app.security.pattern.isolation) and putting a Windows absolute or UNC path in a script src of the isolation index.html, e.g. <script src="C:\js\isolate.js"> or src="\\nas\share\isolate.js">, then building/running on Windows. A Unix-style '/isolation.js' passes because stripping '/' succeeds.

Common situations: Developers on Windows authoring the isolation template with local absolute paths; Windows CI runners; cross-platform projects where a teammate committed a drive-letter path.

Related errors


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/64d34e27c5ddabe3. Report an issue: GitHub.