{"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":"error","filePath":"crates/but-api/src/open/mod.rs","lineNumber":124,"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":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/2497b8007aa4a1922dae9a805b32ffe5b5037785/crates/but-api/src/open/mod.rs#L106-L142","documentation":"open_that() opens a URL or file with the platform opener: it asks the open crate for candidate commands (xdg-open/gio/kde-open on Linux, open on macOS) and runs each with a sanitized environment (AppImage/temp-mount paths stripped from PATH-like vars). If every candidate fails even to spawn (cmd.status() returns Err), the collected per-command failures are returned.","triggerScenarios":"Minimal or headless Linux with no xdg-utils installed; PATH cleaning removed the directory holding the only opener; AppImage-hostile environments; BROWSER unset with no desktop portal available.","commonSituations":"Running in containers or SSH sessions without desktop integration; distros lacking xdg-utils; sandboxed AppImage deployments where the opener path is filtered out.","solutions":["Install xdg-utils so xdg-open exists (Debian/Ubuntu: apt install xdg-utils; Fedora: dnf install xdg-utils)","Set BROWSER and run within a desktop session so the open crate has a usable candidate","Prefer the dedicated open-editor/open-terminal APIs that target specific binaries instead of the generic URL opener","For AppImage/sandbox deployments, verify the opener's path survives the environment cleaning"],"exampleFix":"# before: generic open fails in a headless/minimal environment\n\n# after: provide an opener\nsudo apt install xdg-utils\nexport BROWSER=firefox   # and/or run inside a desktop session","handlingStrategy":"fallback","validationCode":"let opener_available = which::which(\"xdg-open\").is_ok()\n    || which::which(\"gio\").is_ok()\n    || std::env::var_os(\"BROWSER\").is_some();\nif !opener_available {\n    // skip generic open; offer copy-to-clipboard or a specific editor instead\n}","typeGuard":null,"tryCatchPattern":"match open_that(&url) {\n    Err(err) if err.to_string().starts_with(\"Errors occurred\") => {\n        // fall back: copy the URL/path, or launch a known editor binary directly\n    }\n    other => other,\n}","preventionTips":["Ship or require xdg-utils on Linux targets","Test open flows in the minimal environment you deploy to","Keep a specific-binary fallback (editor/terminal open) when the generic opener fails"],"tags":["open","desktop-integration","linux","xdg-open","environment"],"backgroundTag":"process-launch-failed","analyzedSha":"2497b8007aa4a1922dae9a805b32ffe5b5037785","analyzedAt":"2026-08-17T00:30:25.648Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}