gitbutlerapp/gitbutler · error
directory picker failed
Error message
directory picker failed (exit {code}): {} What it means
On Linux, `native_pick_directory` uses `zenity` (with `kdialog` as fallback) to show a folder chooser. Exit code 1 is treated as user cancellation and returns Ok(None); any other non-zero exit produces this error with the process exit code and trimmed stderr (or "unknown error").
Solutions
- Read the exit code and stderr in the message; for display errors, set DISPLAY/WAYLAND_DISPLAY or run inside a graphical session.
- Install a working dialog backend (`zenity` or `kdialog`) and verify it runs, e.g. `zenity --version`.
- Bypass the native picker by providing the path directly through the API/CLI parameter.
- If the tool genuinely exited 1 on cancel but wasn't caught, treat the operation as cancelled and retry or ask the user again.
Defensive patterns
Strategy: fallback
Validate before calling
// Linux: verify a dialog backend and a display exist before requesting the native picker command -v zenity || command -v kdialog; [ -n "$DISPLAY" -o -n "$WAYLAND_DISPLAY" ] && echo ok
Type guard
fn linux_picker_ready(has_zenity: bool, has_kdialog: bool, has_display: bool) -> bool {
has_display && (has_zenity || has_kdialog)
} Try / catch
match pick_directory().await {
Err(e) if e.to_string().contains("directory picker failed") => {
let dir = prompt_for_path_manually(); // fallback to text input
}
other => other?,
} Prevention
- Install zenity or kdialog and confirm it launches in the target environment.
- Ensure DISPLAY/WAYLAND_DISPLAY is set and the process runs in a graphical session.
- Offer a manual path-entry fallback so headless environments still work.
- Remember exit code 1 means the user cancelled (Ok(None)), not a failure.
When it happens
Trigger: Invoking the native directory-pick endpoint on Linux when zenity/kdialog exits with a code other than 0 or 1 — e.g. the dialog tool is installed but cannot open a display, crashes, or is invoked with invalid options in an unsupported desktop environment.
Common situations: Running on a headless Linux box or in a session without DISPLAY/WAYLAND_DISPLAY so zenity fails to open a window; a minimal install where the desktop portal is unavailable; unusual exit codes from wrappers around zenity.
Related errors
- Attempting to restore backup
- Failed to construct but cli URL
- Failed to create window
- Failed to get signature for but, requested version may be…
- Failed to parse URL
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/3fa261e6fab06874.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-server/src/lib.rs:174
.output()
.or_else(|_| {
std::process::Command::new("kdialog")
.args([
"--getexistingdirectory",
".",
"--title",
"Select a Git repository",
])
.output()
})?;
if !output.status.success() {
// zenity exits 1 on cancel, kdialog exits 1 on cancel
let code = output.status.code().unwrap_or(-1);
if code == 1 {
return Ok(None);
}
let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
anyhow::bail!(
"directory picker failed (exit {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(target_os = "windows")]
{
// Use the modern IFileOpenDialog via PowerShell (STA is required forView on GitHub (pinned to 58e5313667)