{"record":{"id":"5da9a06867592b44","repo":"slint-ui/slint","slug":"path-not-found","errorCode":null,"errorMessage":"path not found","messagePattern":"path not found","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"tools/editor/preview.rs","lineNumber":2864,"sourceCode":"    ) -> ComponentInstance {\n        let code = Rc::new(code);\n\n        let path = main_test_file_name();\n        let source_code = code.get(&path).unwrap().clone();\n        let (diagnostics, component_definition, _, _) = spin_on::spin_on(super::parse_source(\n            Default::default(),\n            path,\n            Some(24),\n            source_code.to_string(),\n            style.to_string(),\n            None,\n            move |path| {\n                let code = code.clone();\n                let path = PathBuf::from(&path);\n\n                Box::pin(async move {\n                    let Some(source) = code.get(&path) else {\n                        return Some(Result::Err(std::io::Error::new(\n                            std::io::ErrorKind::NotFound,\n                            \"path not found\",\n                        )));\n                    };\n                    Some(Ok((Some(24), source.clone())))\n                })\n            },\n        ));\n\n        assert!(diagnostics.is_empty());\n\n        component_definition.unwrap().create().unwrap()\n    }\n\n    #[track_caller]\n    pub fn interpret_test(style: &str, source_code: &str) -> ComponentInstance {\n        let code = HashMap::from([(main_test_file_name(), source_code.to_string())]);\n        interpret_test_with_sources(style, code)","sourceCodeStart":2846,"sourceCodeEnd":2882,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/tools/editor/preview.rs#L2846-L2882","documentation":"In the preview's file-load callback (editor-side), the requested path is looked up in the `code` map of known sources. If the map has no entry for that `PathBuf`, the loader returns `NotFound` with the message \"path not found\", aborting compilation of that dependency.","triggerScenarios":"The compiler's file loader requests a path that is not a key in the captured `code` map — e.g. an imported .slint file whose path was never added to the map, or a path whose format differs (relative vs absolute, different separators).","commonSituations":"An import references a file outside the set of files the editor registered; path normalization differences (e.g. `./x.slint` vs `x.slint`) make the map lookup miss; file was deleted or moved after the map was built.","solutions":["Add the missing file's source to the `code` map before compiling, keyed by the same canonical PathBuf the loader will request","Normalize both map keys and lookup paths (canonicalize) so they match exactly","Verify the import path in the .slint file points to a file that exists and is registered with the preview"],"exampleFix":"// before\nlet Some(source) = code.get(&path) else { return Err(NotFound) };\n// after\nlet canonical = path.canonicalize()?;\nlet Some(source) = code.get(&canonical) else { /* register or return NotFound */ };","handlingStrategy":"fallback","validationCode":"if !code.contains_key(&path) {\n    // read the file from disk instead of the cache, or fail early with a clear message\n    let source = std::fs::read_to_string(&path)?;\n}","typeGuard":"fn has_cached_source(code: &HashMap<PathBuf, String>, path: &Path) -> bool {\n    code.contains_key(path)\n}","tryCatchPattern":"match code.get(&path) {\n    Some(source) => Ok((Some(24u32), source.clone())),\n    None => match std::fs::read_to_string(&path) {\n        Ok(src) => Ok((None, src)), // fallback to disk\n        Err(_) => Err(std::io::Error::new(std::io::ErrorKind::NotFound, \"path not found\")),\n    },\n}","preventionTips":["Key the code map with canonicalized absolute paths and canonicalize the lookup path the same way","Keep the cache in sync with file system events (create/rename/delete)","Validate import paths against registered files before compiling"],"tags":["io","paths","cache","live-preview"],"backgroundTag":"file-not-found","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}