tauri-apps/tauri · error
unable to find isolation file
Error message
unable to find isolation file
What it means
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.
Source
Thrown at crates/tauri-utils/src/html2.rs:156
#[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());
let mut i = 0;
while i < input.len() {
match input[i] {View on GitHub (pinned to 56d19c39e4)
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.
Example fix
<!-- before --> <script src="isolation.js"></script> <!-- dist only contains assets/isolation.js --> <!-- after --> <script src="assets/isolation.js"></script>
Defensive patterns
Strategy: validation
Validate before calling
let dist = std::path::Path::new("../path/to/dist");
for src in collect_script_srcs("isolation/index.html") {
let p = dist.join(src.trim_start_matches('/'));
assert!(p.is_file(), "isolation script missing: {}", p.display());
} Prevention
- Verify each referenced script exists in the dist output before building.
- Automate the existence check in the frontend build's post-build step.
When it happens
Trigger: 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.
Common situations: Frontend build not copying the isolation script to dist; path levels off after moving the HTML file; distDir changed without updating script paths.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- unable to find isolation file
- Tauri "Isolation" Pattern only supports relative or absolute
- Tauri "Isolation" Pattern only supports relative or absolute
- File does not exist at path: {path}
- The isolation application path is set to `{dir:?}` but it do
AI-assisted analysis of tauri-apps/tauri@56d19c39e4 (2026-08-20).
Data as JSON: /api/errors/5b9db6aa5440ebe8.
Report an issue: GitHub.