{"record":{"id":"7ce3dd2c2308db40","repo":"gitbutlerapp/gitbutler","slug":"could-not-resolve-application-path-for","errorCode":null,"errorMessage":"Could not resolve application path for '{}'","messagePattern":"Could not resolve application path for '(.+?)'","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but-api/src/open/program.rs","lineNumber":615,"sourceCode":"\n    #[cfg(target_os = \"macos\")]\n    fn find_app_directory(&self) -> anyhow::Result<PathBuf> {\n        use objc2_app_kit::NSWorkspace;\n        use objc2_foundation::NSString;\n\n        let workspace = NSWorkspace::sharedWorkspace();\n        let bundle_identifier = NSString::from_str(&self.bundle_identifier);\n        let app_url = workspace\n            .URLForApplicationWithBundleIdentifier(&bundle_identifier)\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Could not find application for '{}'\",\n                    self.bundle_identifier\n                )\n            })?;\n\n        app_url.to_file_path().ok_or_else(|| {\n            anyhow::anyhow!(\n                \"Could not resolve application path for '{}'\",\n                self.bundle_identifier\n            )\n        })\n    }\n}\n\n#[cfg(target_os = \"macos\")]\nfn open_in_macos_application(\n    app: &MacosApplication,\n    cli_arg_supplier: &CliArgumentSupplier,\n    open_spec: OpenSpec,\n) -> anyhow::Result<()> {\n    match open_spec {\n        OpenSpec::FileAtLine(path, line_nr) => match app.resolve_cli_wrapper_abspath() {\n            Ok(cli_abspath) => {\n                let mut cmd = Command::new(cli_abspath);\n                cli_arg_supplier.open_at_line(&mut cmd, &path, line_nr);","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-api/src/open/program.rs#L597-L633","documentation":"After Launch Services returned a URL for the bundle identifier, MacosApplication::find_app_directory calls to_file_path() on it and that conversion returned None. Launch Services handed back a URL that is not a plain file URL, so it cannot be turned into a filesystem path for the .app directory. This is a defensive check that almost never fires on a healthy system.","triggerScenarios":"URLForApplicationWithBundleIdentifier resolves the bundle id to a non-file URL (custom scheme, network placeholder, or damaged registration) and URL::to_file_path() therefore fails.","commonSituations":"Exotic or stale Launch Services entries pointing at non-file locations, e.g. after restoring a system from a backup or registering apps via unusual installers; essentially only occurs on damaged system state.","solutions":["Reinstall the application so Launch Services points at a normal on-disk .app file URL","Inspect what Launch Services returns for the bundle id and remove the stale registration (lsregister dump, then re-register)","If it persists, report the case upstream together with the URL Launch Services is returning"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match open_in_macos_application(&app, &args, spec) {\n    Err(err) if err.to_string().contains(\"Could not resolve application path\") => {\n        // treat the registration as broken: prompt reinstall or fall back to `open -b`\n    }\n    result => result,\n}","preventionTips":["Surface this as a 'broken app registration' state distinct from 'app not installed'","Log the bundle id involved so support can inspect the Launch Services entry"],"tags":["macos","launch-services","url-conversion"],"backgroundTag":"invalid-file-url-conversion","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}