{"record":{"id":"5f0d1ff8908ddc08","repo":"flxzt/rnote","slug":"could-not-open-file-input-file-file-path-is","errorCode":null,"errorMessage":"Could not open file '{input_file:?}', file path is None.","messagePattern":"Could not open file '(.+?)', file path is None\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-ui/src/appwindow/mod.rs","lineNumber":604,"sourceCode":"                    .dispatch_toast_error(&gettext(\"Opening file failed\"));\n                self.overlays().progressbar_abort();\n            }\n        }\n    }\n\n    /// Internal method for opening/importing content from a file with a supported content type.\n    ///\n    /// Returns Ok(true) if file was imported, Ok(false) if not, Err(_) if the import failed.\n    async fn try_open_file(\n        &self,\n        input_file: gio::File,\n        target_pos: Option<Vector2>,\n        rnote_file_new_tab: bool,\n    ) -> anyhow::Result<bool> {\n        let file_imported = match FileType::lookup_file_type(&input_file) {\n            FileType::RnoteFile => {\n                let input_file_path = input_file.path().ok_or_else(|| {\n                    anyhow::anyhow!(\"Could not open file '{input_file:?}', file path is None.\")\n                })?;\n\n                // we grab focus\n                self.present();\n                // If the file is already opened in a tab, simply switch to it\n                if let Some(page) = self.tabs_query_file_opened(input_file_path) {\n                    self.overlays().tabview().set_selected_page(&page);\n                    false\n                } else {\n                    let (rnote_file_new_tab, wrapper) =\n                        match (rnote_file_new_tab, self.active_tab_wrapper()) {\n                            (true, None) => (true, self.new_canvas_wrapper()),\n                            // Create a new tab when the existing is already used\n                            (true, Some(active_wrapper))\n                                if !active_wrapper.canvas().empty()\n                                    || active_wrapper.canvas().output_file().is_some() =>\n                            {\n                                (true, self.new_canvas_wrapper())","sourceCodeStart":586,"sourceCodeEnd":622,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-ui/src/appwindow/mod.rs#L586-L622","documentation":"try_open_file dispatches on the detected FileType. For FileType::RnoteFile the code needs a native filesystem path (for tab de-duplication and saving the origin path), but Gio::File objects can be non-native (e.g. from portal/URI without a path, or fuse handles); when input_file.path() is None this error is thrown.","triggerScenarios":"Opening an .rnote file whose Gio::File has no backing path — e.g. a file provided as a bare URI (http://, recently-used URI, document portal fd) rather than a native file:// path — via open_file_w_dialogs.","commonSituations":"Opening files passed by non-native sources: xdg-desktop-portal transfers, some 'recent files' entries, files dragged from remote/virtual locations in the file chooser (e.g. smb/gvfs mounts resolved without path), or CLI args that are URIs.","solutions":["Ensure the file is a native local path before calling try_open_file; copy non-native files to a temp location and open the copy.","Use input_file.load_bytes_future() and deserialize rnote bytes directly, avoiding the need for a path when path() is None.","Check file.has_uri_scheme(\"file\") / file.path().is_some() in the caller and show a user-facing error to choose a local file.","If launched via CLI with a URI, convert with Gio::File::for_uri only for file:// schemes, otherwise resolve to a local path first."],"exampleFix":"// before\nlet input_file_path = input_file.path().ok_or_else(|| {\n    anyhow::anyhow!(\"Could not open file '{input_file:?}', file path is None.\")\n})?;\n// after\nlet input_file_path = match input_file.path() {\n    Some(p) => p,\n    None => {\n        // fall back: read bytes and open pathless\n        let (bytes, _) = input_file.load_bytes_future().await?;\n        return self.open_rnote_bytes(bytes.to_vec()).map(|_| true);\n    }\n};","handlingStrategy":"validation","validationCode":"// rust\nif input_file.path().is_none() {\n    eprintln!(\"file {:?} has no native path; copy locally before opening\", input_file.uri());\n}","typeGuard":"fn is_native_file(f: &gio::File) -> bool { f.has_uri_scheme(\"file\") && f.path().is_some() }","tryCatchPattern":"match appwindow.try_open_file(&file, target_pos, new_tab).await {\n    Ok(imported) => { /* ... */ }\n    Err(e) if e.to_string().contains(\"file path is None\") => {\n        // copy to temp then retry\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Only register file:// paths (not raw URIs) when opening files programmatically","Copy portal/gvfs-provided files to a temp dir before calling try_open_file","Check has_uri_scheme(\"file\") in callers that hand files to the app","For recently-used entries, resolve the real local path first"],"tags":["gio","file-path","glib","gtk"],"backgroundTag":"file-not-found","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}