gitbutlerapp/gitbutler · warning

Failed to execute command {cmd:?}

Error message

Failed to execute command {cmd:?}

What it means

On non-Linux platforms, `open_url_in_browser`-style logic iterates `open::commands(url)` (candidate launchers such as `open` on macOS or `cmd /C start` on Windows) and runs `cmd.status()` on each. When a candidate fails to spawn or exits nonzero, this per-command error is collected; if every candidate fails, the caller gets `Errors occurred: [Failed to execute command ...]`. It means the OS could not open the URL with any known browser-launch command.

Source

Thrown at crates/but-path/src/lib.rs:306

            // e.g. run `but gui` in a terminal, and then keep using that terminal.
            //
            // This is only necessary on cold start, i.e. when the GUI isn't already running, as
            // then this process becomes the GUI process. If the GUI is already running, this
            // process effectively just sends the deep link to the already running GUI and then
            // exits.
            cmd.spawn()?;
        };

        #[cfg(not(target_os = "linux"))]
        {
            let mut cmd_errors = Vec::new();
            for mut cmd in open::commands(url.as_str()) {
                cmd.envs(cleaned_vars.clone());
                cmd.current_dir(env::temp_dir());
                if cmd.status().is_ok() {
                    return Ok(());
                } else {
                    cmd_errors.push(anyhow::anyhow!("Failed to execute command {cmd:?}"));
                }
            }
            if !cmd_errors.is_empty() {
                anyhow::bail!("Errors occurred: {cmd_errors:?}");
            }
        }
        Ok(())
    }
}

fn build_open_url(
    scheme: &str,
    possibly_project_dir: &std::path::Path,
    timestamp: u128,
    new_window: bool,
) -> anyhow::Result<url::Url> {
    let mut url = url::Url::parse(&format!("{scheme}://open"))?;
    url.query_pairs_mut()

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Run the command from an interactive GUI session where a default browser is configured
  2. Verify the URL being passed is well-formed (scheme + host)
  3. Set/configure a default browser for the user account, or ensure the launcher (`open`, `cmd`) is on PATH
  4. In code, treat failure as non-fatal: log the warning and surface the URL to the user so they can open it manually

Example fix

// before
open_url_in_browser(&url)?; // Errors occurred: [Failed to execute command ...]

// after
if let Err(e) = open_url_in_browser(&url) {
    log::warn!("could not open browser ({e:#}); please visit {url} manually");
}
Defensive patterns

Strategy: fallback

Try / catch

if let Err(e) = but_path::open_url_in_browser(&url) {
    // every candidate launcher failed; degrade to showing the URL
    log::warn!("failed to open browser ({e:#})");
    println!("Open this URL manually: {url}");
}

Prevention

When it happens

Trigger: Running on macOS/Windows in a headless or locked-down session (CI runner, SSH without GUI, sandbox) where `open`/`start` fails; a URL no handler accepts; PATH so stripped the launcher binary cannot be found; a launcher that exits nonzero (e.g. no default browser configured).

Common situations: Automation invoking the CLI (`but gui`) on headless macOS/Windows runners; kiosk or restricted user accounts with no default browser; AppImage/sandboxed environments on non-Linux targets.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/00fcc56dd1041771. Report an issue: GitHub.