fix: solve #4599 — strip EDITOR/GIT_EDITOR so git ≥ 2.50 stops blocking workspace spawns
Root cause
Git 2.50 added a security check that refuses to honor inherited EDITOR / GIT_EDITOR env vars on non-interactive callers, emitting:
Use of "EDITOR" is not permitted without enabling allowUnsafeEditor
simple-git surfaces this as GitPluginError, which is what fires when users try to spawn a new workspace (reported in #4599 against 1.9.5).
The same class of error already broke us once for PAGER/GIT_PAGER, and apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts already strips those in getProcessEnvWithShellPath. The fix just extends that allowlist to EDITOR / GIT_EDITOR.
The fix
apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts:206-211 — delete EDITOR and GIT_EDITOR alongside PAGER and GIT_PAGER before returning the env that gets piped into simple-git / execGit. Programmatic git children never prompt for commit messages or hunk edits, so no replacement value is needed. User-facing terminals continue to inherit EDITOR from the interactive shell (this code path doesn't run for them).
Why this is safe
getProcessEnvWithShellPathis only used to build env for the host-service / desktop main process's owngitchildren (getSimpleGitWithShellPath,execGitWithShellPath).- Those children all run with piped stdio and never invoke
git commit/git rebase -i/git add -p, so an editor never needs to launch. - This mirrors the existing
PAGER/GIT_PAGERstrip and the rationale documented inline.
Tests
apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.test.ts — added two cases under getProcessEnvWithShellPath strips unsafe git env vars:
strips PAGER and GIT_PAGER from the returned env(pins existing behavior so it can't regress)strips EDITOR and GIT_EDITOR from the returned env(the bug — fails onmain, passes with the fix)
Full suite at apps/desktop/src/lib/trpc/routers/workspaces/utils/: 203 pass / 0 fail.
Closes #4599
Summary by cubic
Prevents workspace creation from failing on Git ≥ 2.50 by stripping EDITOR/GIT_EDITOR from env for non-interactive git calls, matching existing PAGER/GIT_PAGER logic. Fixes #4599.
- Bug Fixes
- Remove EDITOR and GIT_EDITOR in getProcessEnvWithShellPath before calling
simple-git/execGit. - Scope: only programmatic git children; user terminals keep their EDITOR.
- Tests added for both PAGER/GIT_PAGER and EDITOR/GIT_EDITOR stripping.
- Remove EDITOR and GIT_EDITOR in getProcessEnvWithShellPath before calling