gitbutlerapp/gitbutler · error · anyhow::Error
Unsupported platform
Error message
Unsupported platform
What it means
open_in_terminal(terminal_id, path) in but-api launches a terminal at a directory. It has explicit branches for macOS, Linux (cfg!(target_os = "linux")), and Windows; every other compile target falls through to this unconditional bail. The error means the binary you are running was built for a platform the terminal-launching code simply does not cover.
Source
Thrown at crates/but-api/src/open/mod.rs:586
cmd.current_dir(canonical_path)
// Keep the window open
.arg("-NoExit");
create_new_console(&mut cmd);
spawn_and_reap(cmd, "PowerShell", canonical_path)?;
}
"cmd" => {
// Set the working directory directly - OS handles path format
let mut cmd = Command::new("cmd");
cmd.current_dir(canonical_path)
// Keep the window open
.arg("/K");
create_new_console(&mut cmd);
spawn_and_reap(cmd, "Command Prompt", canonical_path)?;
}
_ => bail!("Unknown terminal: {terminal_id}"),
};
} else {
bail!("Unsupported platform");
}
Ok(())
}
/// Reveals the file or directory at `path` in the platform's file manager.
///
/// On macOS this reveals the item in Finder, on Windows it selects the item in
/// Explorer, and on Linux it opens either the directory itself or the file's
/// parent directory.
#[but_api]
#[instrument(err(Debug))]
pub fn show_in_finder(path: String) -> Result<()> {
// Cross-platform implementation to open file/directory in the default file manager
// macOS: Opens in Finder (with -R flag to reveal the item)
// Windows: Opens in File Explorer
// Linux: Opens in the default file manager
View on GitHub (pinned to caf1f223d3)
Solutions
- Run the app/CLI on macOS, Linux, or Windows - the supported platforms for terminal launching
- Gate the 'open in terminal' feature in your UI/CLI on the host platform instead of letting the call fail
- If you must support another OS, add a platform branch plus a terminal-id-to-binary mapping in crates/but-api/src/open/mod.rs and crates/but-api/src/open/terminal.rs
Example fix
// before (TS/SDK caller, always shown)
await sdk.openInTerminal(terminalId, path);
// after
const supported = ['Darwin', 'Linux', 'Windows_NT'].includes(os.type());
if (supported) {
await sdk.openInTerminal(terminalId, path);
} else {
showInfo('Opening a terminal is not supported on this platform');
} Defensive patterns
Strategy: validation
Validate before calling
// TypeScript caller: gate the action on the host platform
const TERMINAL_PLATFORMS = new Set(['Darwin', 'Linux', 'Windows_NT']);
if (!TERMINAL_PLATFORMS.has(os.type())) {
throw new Error(`open_in_terminal: unsupported platform ${os.type()}`);
}
await api.openInTerminal(terminalId, path); Prevention
- Hide the 'open in terminal' action on any platform other than macOS, Linux, Windows instead of letting the call fail
- When porting to a new OS target, remember open/mod.rs is a cfg chain - add the branch before shipping the build
- Treat this error as permanent for the session: do not retry, promptless-ly disable the feature
When it happens
Trigger: Invoking open_in_terminal (Tauri command, N-API/SDK openInTerminal, or CLI equivalent) from a build targeting anything other than macOS, Linux, or Windows - e.g. FreeBSD/OpenBSD/illumos builds, or a custom cross-compile target. Note this is a compile-time cfg chain, so the same call site never fails on a supported platform.
Common situations: Running the but CLI or embedding but-api on a BSD or niche OS; wasm/emscripten experimental builds; CI cross-compilation smoke tests against unusual targets.
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
- validated AI responses only produce content picks
- {terminal_name} exited with non-zero status: {status_code}
- Failed to open {terminal_name} ({status_code}): {stderr}
- Unknown terminal: {terminal_id}
- Path does not exist: {path}
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/c688532cde6a1dc4.
Report an issue: GitHub.