Skip to content

fix(desktop): force GIT_PAGER=cat to dodge Apple Git 2.50+ block#4568

Merged
saddlepaddle merged 1 commit into
mainfrom
saddlepaddle/git-pager-fix
May 14, 2026
Merged

fix(desktop): force GIT_PAGER=cat to dodge Apple Git 2.50+ block#4568
saddlepaddle merged 1 commit into
mainfrom
saddlepaddle/git-pager-fix

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented May 14, 2026

Summary

Apple Git 2.50 (shipped in macOS Sequoia 15.5+ and current Homebrew) refuses to honor an inherited PAGER env var on non-interactive callers, erroring with:

```
Use of "PAGER" is not permitted without enabling allowUnsafePager
```

simple-git wraps that stderr as GitPluginError, which breaks every git read path used by workspace creation — git status, git worktree list, git worktree prune, git for-each-ref — and bubbles up to the renderer as "Couldn't create workspace".

Fix

One-liner in getProcessEnvWithShellPath (apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts), which is the single env builder used by both:

  • desktop's simple-git wrapper (getSimpleGitWithShellPath)
  • the host-service child spawn (host-service-coordinator.ts:515)

Setting GIT_PAGER=cat cascades to all simple-git calls in desktop main + the host-service's process.env → inherited by every simpleGit() call inside host-service (13 callsites, mostly without explicit .env() overrides).

GIT_PAGER takes precedence over PAGER for git, so users' interactive terminals still see their preferred pager (delta, less, etc.). Only git inside non-interactive helpers is silenced — pagers are useless in programmatic git invocations anyway.

Test plan

  • CI green
  • On macOS with Apple Git 2.50+ and PAGER set in login shell: open Canary → New Workspace → workspace creates without error
  • ~/.superset/host/<org>/host-service.log no longer shows GitPluginError: Use of "PAGER" is not permitted... lines
  • Terminal sessions still respect user's PAGER for non-git tools

Background log evidence (Satya's local Canary)

```
[git/getBranchSyncStatus] git.status() failed; treating working tree as clean for this read GitPluginError: Use of "PAGER" is not permitted without enabling allowUnsafePager
[workspace-creation] git worktree list failed: GitPluginError: Use of "PAGER" is not permitted without enabling allowUnsafePager
[workspaceCreation.searchBranches] git for-each-ref failed: GitPluginError: Use of "PAGER" is not permitted without enabling allowUnsafePager
[workspaces.create] worktree prune failed: GitPluginError: Use of "PAGER" is not permitted without enabling allowUnsafePager
```


Summary by cubic

Strip PAGER and GIT_PAGER from the env for all desktop and host-service git calls to avoid Apple Git 2.50+ blocking inherited pager vars in non-interactive runs. This restores workspace creation and other git reads while leaving interactive terminals unchanged.

  • Bug Fixes
    • Remove PAGER and GIT_PAGER in getProcessEnvWithShellPath, cascading to all simple-git calls and host-service spawns (fixes git status, worktree ops, and ref listing).
    • Only set PATH/Path when shellPath is present.

Written for commit 2570c92. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • Prevented non-interactive git commands from using host paging so output appears consistently without unexpected pagers.
    • Improved environment PATH handling so the app only adopts shell PATH when one is actually provided, avoiding accidental overrides.

Review Change Stack

@capy-ai
Copy link
Copy Markdown

capy-ai Bot commented May 14, 2026

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aff77286-bdb6-48ef-8c51-e8c9220024fa

📥 Commits

Reviewing files that changed from the base of the PR and between e690941 and 2570c92.

📒 Files selected for processing (1)
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts

📝 Walkthrough

Walkthrough

getProcessEnvWithShellPath now applies a shell-derived PATH only when available (no early return) and removes both env.PAGER and env.GIT_PAGER from the returned environment.

Changes

Git Pager and Shell PATH Configuration

Layer / File(s) Summary
Conditional shell PATH application
apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts
getProcessEnvWithShellPath no longer returns early when a shell-derived PATH is missing; it conditionally updates env.PATH / env.Path only if shellPath is present.
Remove pager environment variables
apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts
The function deletes env.PAGER and env.GIT_PAGER from the returned environment so non-interactive git subprocesses do not inherit paging behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit peeks from leafy stacks,
Tweaks the PATH, then gently packs
Pagers away, no screens to stall —
Subprocesses answer every call.
Hop on, code flows, no prompts to track. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly references the core fix: preventing Apple Git 2.50+ from blocking GIT_PAGER, which is the primary change and motivation for this PR.
Description check ✅ Passed The description provides comprehensive context including problem statement, fix explanation, test plan, and background logs. It follows the template structure with clear sections addressing Type of Change (bug fix), Testing, and Additional Notes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch saddlepaddle/git-pager-fix

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 14, 2026

Greptile Summary

This PR fixes a workspace-creation breakage on macOS with Apple Git 2.50+ (Sequoia 15.5 / current Homebrew), which refuses to honour an inherited PAGER env var in non-interactive callers, causing simple-git to surface GitPluginError: Use of "PAGER" is not permitted without enabling allowUnsafePager across every git read path the desktop uses.

  • Adds env.GIT_PAGER = \"cat\" at the end of getProcessEnvWithShellPath, which is the single env builder consumed by the simple-git wrapper and the host-service child spawn; GIT_PAGER takes precedence over PAGER so interactive terminals keep their configured pager untouched.
  • Refactors the early-return on a missing shellPath to a positive conditional, ensuring GIT_PAGER is always set even when the shell-PATH lookup comes back empty.

Confidence Score: 4/5

Safe to merge — the change is a small, well-contained one-liner that fixes a real workspace-creation failure on Apple Git 2.50+.

The fix is correct and clearly motivated. The only gap is that execWithShellEnv, which calls getProcessEnvWithShellEnv directly rather than getProcessEnvWithShellPath, does not inherit GIT_PAGER=cat. If any git invocation currently or in the future routes through that helper, it would remain exposed to the same Apple Git error.

shell-env.ts — specifically whether execWithShellEnv callers include any git operations that would bypass the fix.

Important Files Changed

Filename Overview
apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts Adds env.GIT_PAGER = "cat" to getProcessEnvWithShellPath and refactors the early-return on missing PATH to a positive conditional, ensuring the pager override is always applied. execWithShellEnv still uses getProcessEnvWithShellEnv directly and won't inherit this fix.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["getProcessEnvWithShellPath(baseEnv)"] --> B["getShellEnvironment()"]
    B --> C["getProcessEnvWithShellEnv(baseEnv, shellEnvResult)\n(existing values win)"]
    C --> D{shellPath found?}
    D -- Yes --> E["env.PATH = shellPath\n(+ env.Path on win32)"]
    D -- No --> F[skip PATH assignment]
    E --> G["env.GIT_PAGER = 'cat' ← NEW"]
    F --> G
    G --> H["return env"]

    H --> I["getSimpleGitWithShellPath\n(simple-git wrapper)"]
    H --> J["host-service-coordinator.ts:515\n(child spawn)"]

    K["execWithShellEnv(cmd, args)"] --> L["getProcessEnvWithShellEnv only\n⚠️ GIT_PAGER NOT set here"]
Loading

Comments Outside Diff (1)

  1. apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts, line 213-226 (link)

    P2 execWithShellEnv misses the GIT_PAGER fix

    execWithShellEnv (line 213) calls getProcessEnvWithShellEnv directly — not getProcessEnvWithShellPath — so any git command routed through it will not carry GIT_PAGER=cat and remains exposed to the same Apple Git 2.50+ block. If any current or future caller passes a git binary through execWithShellEnv, the fix won't apply. Moving the GIT_PAGER assignment into getProcessEnvWithShellEnv (which is called by both paths) would close this gap universally.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts
    Line: 213-226
    
    Comment:
    **`execWithShellEnv` misses the `GIT_PAGER` fix**
    
    `execWithShellEnv` (line 213) calls `getProcessEnvWithShellEnv` directly — not `getProcessEnvWithShellPath` — so any git command routed through it will not carry `GIT_PAGER=cat` and remains exposed to the same Apple Git 2.50+ block. If any current or future caller passes a git binary through `execWithShellEnv`, the fix won't apply. Moving the `GIT_PAGER` assignment into `getProcessEnvWithShellEnv` (which is called by both paths) would close this gap universally.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts:213-226
**`execWithShellEnv` misses the `GIT_PAGER` fix**

`execWithShellEnv` (line 213) calls `getProcessEnvWithShellEnv` directly — not `getProcessEnvWithShellPath` — so any git command routed through it will not carry `GIT_PAGER=cat` and remains exposed to the same Apple Git 2.50+ block. If any current or future caller passes a git binary through `execWithShellEnv`, the fix won't apply. Moving the `GIT_PAGER` assignment into `getProcessEnvWithShellEnv` (which is called by both paths) would close this gap universally.

Reviews (1): Last reviewed commit: "fix(desktop): force GIT_PAGER=cat to dod..." | Re-trigger Greptile

Git ≥ 2.50 refuses to honor an *inherited* PAGER or GIT_PAGER env on
non-interactive callers, erroring with:

    Use of "PAGER" is not permitted without enabling allowUnsafePager
    (or "GIT_PAGER", if that's the one set)

simple-git wraps that stderr as GitPluginError and breaks every git
read path used by workspace creation — git status, git worktree list,
git worktree prune, git for-each-ref — surfacing in the renderer as
"Couldn't create workspace".

The first version of this PR set GIT_PAGER=cat to override PAGER, but
git also rejects an inherited GIT_PAGER under the same check, so CI
turned up the same error with the variable name swapped (visible in
the hasUnpushedCommits test fallbacks).

Right fix: delete both. simple-git's git children have piped stdout
(not a TTY), so git skips paging entirely — no replacement value is
needed. Interactive user terminals get their own PAGER/GIT_PAGER from
the login shell snapshot, so this only affects the host-service /
desktop-main process's own git children.

`getProcessEnvWithShellPath` is the single env builder for both
desktop's simple-git wrapper (`getSimpleGitWithShellPath`) and the
host-service child spawn (`host-service-coordinator.ts:515`). Stripping
the pager vars here cascades to:
  - all simple-git calls in desktop main
  - the host-service's `process.env` → inherited by every simpleGit()
    call inside host-service (13 callsites)
@saddlepaddle saddlepaddle force-pushed the saddlepaddle/git-pager-fix branch from e690941 to 2570c92 Compare May 14, 2026 16:45
@saddlepaddle saddlepaddle merged commit caefe8d into main May 14, 2026
9 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch

Thank you for your contribution! 🎉

github-actions Bot added a commit that referenced this pull request May 15, 2026
simple-git's @simple-git/argv-parser (since v3.36) rejects inherited
EDITOR/GIT_EDITOR env vars unless allowUnsafeEditor is set, surfacing
as "Use of \"EDITOR\" is not permitted without enabling allowUnsafeEditor"
and breaking workspace creation, status reads, worktree prune, etc. for
any user with EDITOR exported in their shell.

#4568 already fixed the PAGER half by stripping PAGER/GIT_PAGER from
getProcessEnvWithShellPath, which builds the env for both the desktop
simple-git wrapper and the host-service spawn. Extend the same strip
to EDITOR/GIT_EDITOR — none of our scripted git plumbing opens an editor.

Adds a reproduction test plus a sibling PAGER test to lock in the
existing #4568 behavior.
MocA-Love pushed a commit to MocA-Love/superset that referenced this pull request May 25, 2026
…ns (superset-sh#4568)

Git ≥ 2.50 refuses to honor an *inherited* PAGER or GIT_PAGER env on
non-interactive callers, erroring with:

    Use of "PAGER" is not permitted without enabling allowUnsafePager
    (or "GIT_PAGER", if that's the one set)

simple-git wraps that stderr as GitPluginError and breaks every git
read path used by workspace creation — git status, git worktree list,
git worktree prune, git for-each-ref — surfacing in the renderer as
"Couldn't create workspace".

The first version of this PR set GIT_PAGER=cat to override PAGER, but
git also rejects an inherited GIT_PAGER under the same check, so CI
turned up the same error with the variable name swapped (visible in
the hasUnpushedCommits test fallbacks).

Right fix: delete both. simple-git's git children have piped stdout
(not a TTY), so git skips paging entirely — no replacement value is
needed. Interactive user terminals get their own PAGER/GIT_PAGER from
the login shell snapshot, so this only affects the host-service /
desktop-main process's own git children.

`getProcessEnvWithShellPath` is the single env builder for both
desktop's simple-git wrapper (`getSimpleGitWithShellPath`) and the
host-service child spawn (`host-service-coordinator.ts:515`). Stripping
the pager vars here cascades to:
  - all simple-git calls in desktop main
  - the host-service's `process.env` → inherited by every simpleGit()
    call inside host-service (13 callsites)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant