{"record":{"id":"53940538cfbd23ff","repo":"gitbutlerapp/gitbutler","slug":"failed-to-execute-command-cmd","errorCode":null,"errorMessage":"Failed to execute command {cmd:?}","messagePattern":"Failed to execute command (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/but-api/src/open/mod.rs","lineNumber":125,"sourceCode":"            \"GTK_DATA_PREFIX\",\n            \"GTK_EXE_PREFIX\",\n            \"GTK_IM_MODULE_FILE\",\n            \"GTK_PATH\",\n            \"LD_LIBRARY_PATH\",\n            \"PATH\",\n            \"PERLLIB\",\n            \"PYTHONHOME\",\n            \"PYTHONPATH\",\n            \"QT_PLUGIN_PATH\",\n            \"XDG_DATA_DIRS\",\n        ]);\n\n        cmd.envs(cleaned_vars);\n        cmd.current_dir(env::temp_dir());\n        if cmd.status().is_ok() {\n            return Ok(());\n        } else {\n            cmd_errors.push(anyhow::anyhow!(\"Failed to execute command {cmd:?}\"));\n        }\n    }\n    if !cmd_errors.is_empty() {\n        bail!(\"Errors occurred: {cmd_errors:?}\");\n    }\n    Ok(())\n}\n\n/// Opens supported editor URLs directly inside WSL.\n///\n/// The normal URL opener can fail to route `vscode://file/...`-style URLs back\n/// to Linux editor CLIs when GitButler runs in WSL, so this attempts a direct\n/// invocation first. Returns `true` only when a supported editor command was\n/// executed successfully; unsupported URLs and failed launches fall back to the\n/// generic opener.\nfn open_editor_url_as_command_invocation_on_wsl(target_url: &Url) -> bool {\n    use std::process::Command;\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/open/mod.rs#L107-L143","documentation":"`open_that` tries a sequence of platform opener commands (xdg-open, open, explorer, etc.) with a scrubbed environment and temp cwd; if a command spawns but exits non-zero (`cmd.status().is_ok()` false), it records \"Failed to execute command {cmd:?}\". If all candidates fail, it bails with the accumulated errors. This indicates the opener program ran but could not open the target (or the platform opener is broken/unavailable).","triggerScenarios":"Calling open_url/show_in_finder on a system where the opener command exists but fails: missing desktop environment (headless Linux, SSH session, CI), DISPLAY/WAYLAND not set, the URL/path target doesn't exist or is blocked, or the environment was over-scrubbed so the opener lacks needed variables.","commonSituations":"Running the desktop tooling over SSH without X/Wayland; containers/headless servers; broken xdg-open configuration (no default handler for the URL scheme); attempting to open files that were deleted.","solutions":["Open the URL/path manually or in a session with a desktop environment (set DISPLAY/WAYLAND_DISPLAY).","Check that a default handler exists: `xdg-mime query default x-scheme-handler/https` and set one with `xdg-settings set default-web-browser …`.","Verify the target file/URL still exists and is accessible.","On headless systems, copy the URL/path from logs instead of relying on the open command."],"exampleFix":"// before\nopen_url(\"https://example.com\")?; // fails headless\n// after\nmatch open_url(\"https://example.com\") {\n    Ok(()) => {},\n    Err(e) => { eprintln!(\"Could not open browser ({e}); URL: https://example.com\"); }\n}","handlingStrategy":"fallback","validationCode":"// headless check: skip opening when there is no display (Linux)\nif std::env::var_os(\"DISPLAY\").is_none() && std::env::var_os(\"WAYLAND_DISPLAY\").is_none()\n    && cfg!(target_os = \"linux\") {\n    eprintln!(\"no display available; print the URL instead of opening a browser\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"match open_url(url) {\n    Err(e) if e.to_string().contains(\"Failed to execute command\") => {\n        eprintln!(\"auto-open failed ({e}); open manually: {url}\");\n    }\n    other => other?,\n}","preventionTips":["Don't rely on auto-open in SSH/CI/container environments; log the URL/path as fallback","Ensure a default handler is configured (xdg-settings / xdg-mime) on Linux desktops","Verify the target file or URL exists before attempting to open it"],"tags":["os","process","headless","environment"],"backgroundTag":"command-not-found","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"}