{"record":{"id":"f3573b8abe0d625f","repo":"gitbutlerapp/gitbutler","slug":"native-file-picker-is-not-supported-on-this-platfo","errorCode":null,"errorMessage":"Native file picker is not supported on this platform","messagePattern":"Native file picker is not supported on this platform","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-server/src/lib.rs","lineNumber":225,"sourceCode":"                \"PowerShell directory picker failed (exit {:?}): {}\",\n                output.status.code(),\n                if stderr.is_empty() {\n                    \"unknown error\"\n                } else {\n                    &stderr\n                }\n            );\n        }\n        let path = String::from_utf8_lossy(&output.stdout).trim().to_string();\n        if path.is_empty() {\n            return Ok(None);\n        }\n        Ok(Some(path))\n    }\n\n    #[cfg(not(any(target_os = \"macos\", target_os = \"linux\", target_os = \"windows\")))]\n    {\n        anyhow::bail!(\"Native file picker is not supported on this platform\")\n    }\n}\n\nfn cmd_result_to_json(res: anyhow::Result<serde_json::Value>) -> Json<serde_json::Value> {\n    match res {\n        Ok(value) => Json(json!(Response::Success(value))),\n        Err(e) => {\n            let e = json::Error::from(e);\n            Json(json!(Response::Error(json!(e))))\n        }\n    }\n}\n\n/// Check if an origin byte string is from localhost.\n///\n/// Matches `http(s)://localhost`, `http(s)://127.0.0.1`, and\n/// `http(s)://[::1]`, each optionally followed by `:<port>`.\npub(crate) fn is_localhost_origin(origin: &[u8]) -> bool {","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-server/src/lib.rs#L207-L243","documentation":"`native_pick_directory` only implements native folder choosers for macOS (osascript), Linux (zenity/kdialog), and Windows (PowerShell WinForms), gated by `#[cfg(...)]` attributes. On any other target the `#[cfg(not(any(...)))]` branch unconditionally bails with this message — the feature simply does not exist on that platform.","triggerScenarios":"Calling the native directory-picker endpoint in a but-server build for an OS other than macOS, Linux, or Windows (e.g. FreeBSD, or a wasm/non-std target), or running a cross-compiled binary whose cfg gates excluded the picker implementations (crates/but-server/src/lib.rs:224).","commonSituations":"Running but-server on an unsupported/unusual Unix flavor; embedding the server in a non-desktop target; testing a cross-compiled build where no native picker was compiled in.","solutions":["Run on a supported platform (macOS, Linux, or Windows) where a native picker is compiled in.","Provide the directory path directly via the API/CLI instead of invoking the native picker.","If you must support the platform, extend `native_pick_directory` with a new cfg branch implementing a picker (or a plain path prompt fallback)."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Only call the picker on platforms with a compiled-in implementation\nif cfg!(any(target_os = \"macos\", target_os = \"linux\", target_os = \"windows\")) {\n    pick_directory().await?;\n} else {\n    let dir = prompt_for_path_manually();\n}","typeGuard":"fn native_picker_available() -> bool {\n    cfg!(any(target_os = \"macos\", target_os = \"linux\", target_os = \"windows\"))\n}","tryCatchPattern":"match pick_directory().await {\n    Err(e) if e.to_string().contains(\"not supported on this platform\") => {\n        let dir = prompt_for_path_manually(); // non-native fallback\n    }\n    other => other?,\n}","preventionTips":["Gate picker calls behind a platform check (cfg! or a capability flag).","Always ship a non-native path-entry fallback for unsupported targets.","Document platform support for the picker endpoint in client code."],"tags":["platform","native-dialog","unsupported"],"backgroundTag":"unsupported-platform","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}