{"record":{"id":"98ae103bf2ce51d9","repo":"slint-ui/slint","slug":"not-an-absolute-file-path-path-display","errorCode":null,"errorMessage":"Not an absolute file path: {path_display}","messagePattern":"Not an absolute file path: (.+?)","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"internal/live-preview/preview_sessions.rs","lineNumber":299,"sourceCode":"    }\n\n    fn create_compiler(self: &Rc<Self>) -> slint_interpreter::Compiler {\n        let mut compiler = slint_interpreter::Compiler::new();\n\n        let file_loader_session = Rc::downgrade(self);\n        compiler.set_file_loader(move |path: &std::path::Path| {\n            let url = Url::from_file_path(path);\n            let path_display = path.display().to_string();\n            let session = file_loader_session.clone();\n            Box::pin(async move {\n                let Some(session) = session.upgrade() else {\n                    return Some(Err(std::io::Error::new(\n                        std::io::ErrorKind::BrokenPipe,\n                        \"Preview session is no longer available\",\n                    )));\n                };\n                let Ok(url) = url else {\n                    return Some(Err(std::io::Error::new(\n                        std::io::ErrorKind::InvalidInput,\n                        format!(\"Not an absolute file path: {path_display}\"),\n                    )));\n                };\n                Some(session.request_file(url).await.map(|file_content| {\n                    String::from_utf8_lossy(&file_content.contents).to_string()\n                }))\n            })\n        });\n\n        let mapper_session = Rc::downgrade(self);\n        compiler.compiler_configuration(InternalToken).resource_url_mapper =\n            Some(Rc::new(move |url: &Url| {\n                let session = mapper_session.clone();\n                let url = url.clone();\n                Box::pin(async move {\n                    if url.scheme() != \"file\" {\n                        return None;","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/live-preview/preview_sessions.rs#L281-L317","documentation":"The Slint compiler's file loader in the live-preview session can only resolve imported files that map to a `file://` URL. When a compiler import resolves to a relative (non-absolute) path, `Url::from_file_path` fails and the session rejects the load with `InvalidInput`. It exists because the preview loads dependencies over URLs, not raw paths.","triggerScenarios":"A `.slint` import inside the compiled file resolves to a relative path (e.g. an import whose path is relative and the loader callback receives it non-absolute), so `Url::from_file_path(path)` returns `Err` in the `set_file_loader` closure of `create_compiler`.","commonSituations":"Importing a sibling `.slint` file with a relative path that the compiler hands to the file loader unresolved; files loaded from a working directory that differs from the one assumed; embedded/project-relative import strings not normalized to absolute paths before compilation.","solutions":["Make sure imports are resolved to absolute paths before compilation (canonicalize the main file's directory and pass absolute paths in the import path resolver)","Check the import statement in the .slint source — replace ambiguous relative paths with absolute ones or fix the base directory","Pass an explicit include/import path configuration to the compiler so relative imports resolve before the loader sees them"],"exampleFix":"// before\nimport { Widget } from \"widgets/widget.slint\";\n// after (resolve to absolute when configuring the compiler)\nlet abs = std::fs::canonicalize(\"widgets/widget.slint\")?;\ncompiler.import_path_resolver(...); // hand back absolute paths","handlingStrategy":"validation","validationCode":"if !path.is_absolute() {\n    return Err(std::io::Error::new(\n        std::io::ErrorKind::InvalidInput,\n        format!(\"Not an absolute file path: {}\", path.display()),\n    ));\n}\nlet url = Url::from_file_path(path).expect(\"absolute path converts to file URL\");","typeGuard":"fn is_loadable_path(p: &std::path::Path) -> bool {\n    p.is_absolute() && Url::from_file_path(p).is_ok()\n}","tryCatchPattern":null,"preventionTips":["Always canonicalize import paths with std::fs::canonicalize before handing them to the compiler","Configure the compiler's import path resolver so relative imports resolve to absolute paths","Unit-test your file loader with relative-path imports to catch this early"],"tags":["io","paths","compiler","live-preview"],"backgroundTag":"invalid-url-format","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}