gitbutlerapp/gitbutler · error
Native file picker is not supported on this platform
Error message
Native file picker is not supported on this platform
What it means
`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.
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).
Defensive patterns
Strategy: type-guard
Validate before calling
// Only call the picker on platforms with a compiled-in implementation
if cfg!(any(target_os = "macos", target_os = "linux", target_os = "windows")) {
pick_directory().await?;
} else {
let dir = prompt_for_path_manually();
} Type guard
fn native_picker_available() -> bool {
cfg!(any(target_os = "macos", target_os = "linux", target_os = "windows"))
} Try / catch
match pick_directory().await {
Err(e) if e.to_string().contains("not supported on this platform") => {
let dir = prompt_for_path_manually(); // non-native fallback
}
other => other?,
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- Unsupported platform
- Ad-hoc (single-branch) branch moves are not supported…
- Automatic CLI installation is only supported on macOS. See…
- Azure is unsupported at the minute. Sorry 😞.
- bare repositories are not supported
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/f3573b8abe0d625f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-server/src/lib.rs:225
"PowerShell directory picker failed (exit {:?}): {}",
output.status.code(),
if stderr.is_empty() {
"unknown error"
} else {
&stderr
}
);
}
let path = String::from_utf8_lossy(&output.stdout).trim().to_string();
if path.is_empty() {
return Ok(None);
}
Ok(Some(path))
}
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
{
anyhow::bail!("Native file picker is not supported on this platform")
}
}
fn cmd_result_to_json(res: anyhow::Result<serde_json::Value>) -> Json<serde_json::Value> {
match res {
Ok(value) => Json(json!(Response::Success(value))),
Err(e) => {
let e = json::Error::from(e);
Json(json!(Response::Error(json!(e))))
}
}
}
/// Check if an origin byte string is from localhost.
///
/// Matches `http(s)://localhost`, `http(s)://127.0.0.1`, and
/// `http(s)://[::1]`, each optionally followed by `:<port>`.
pub(crate) fn is_localhost_origin(origin: &[u8]) -> bool {View on GitHub (pinned to 58e5313667)