Skip to content

fix(git): preserve env-backed simple-git behavior#323

Merged
MocA-Love merged 2 commits intomainfrom
fix/simple-git-pager-env
Apr 18, 2026
Merged

fix(git): preserve env-backed simple-git behavior#323
MocA-Love merged 2 commits intomainfrom
fix/simple-git-pager-env

Conversation

@MocA-Love
Copy link
Copy Markdown
Owner

@MocA-Love MocA-Love commented Apr 18, 2026

概要

Desktop 1.5.5 相当で入った simple-git 3.36+ の block-unsafe-operations により、ユーザーの shell / credential provider から渡される通常の env が原因で Git 操作が失敗する。

代表例:

Use of "PAGER" is not permitted without enabling allowUnsafePager

当初は unsafe な env を strip する案だったが、その方式だと GIT_SSH_COMMAND / GIT_ASKPASS / GIT_CONFIG_* 依存の clone / fetch / push / auth フローを壊す。

この PR では、既存の env ベース挙動を維持したまま、simple-git 側に必要な allowUnsafe* だけを与える形に修正した。

原因

  • simple-git 3.36+PAGER, EDITOR, GIT_ASKPASS, GIT_SSH_COMMAND, GIT_CONFIG_* などを "unsafe" として検出する
  • desktop 側は getProcessEnvWithShellPath() で shell env を継承して simple-git に渡している
  • host-service 側も credential provider 経由で GIT_ASKPASS や local env を simple-git に渡している
  • そのため、Git タブだけでなく clone / import / fetch / push / author 取得 / workspace 作成系まで同じ種類の failure が起こりうる

対応

  • @superset/shared/simple-git-unsafebuildSimpleGitUnsafeOptions() を追加
  • 継承した env と GIT_CONFIG_COUNT / GIT_CONFIG_KEY_n を解析して、必要な allowUnsafe* だけを導出
  • desktop:
    • getSimpleGitWithShellPath() を新 helper ベースに置き換え
    • progress clone の simpleGit() 直呼びも同じ helper に統一
    • raw git 実行 (execGitWithShellPath*) からは env strip を除去
  • host-service:
    • credential factory を helper ベースに置き換え
    • project/workspace/workspace-creation 内の simpleGit() 直呼び clone/import 経路も同じ helper に統一

期待する効果

  • PAGER / GIT_PAGER / EDITOR が設定された shell 環境でも desktop の Git タブや worktree 操作が壊れない
  • GIT_SSH_COMMAND / GIT_ASKPASS / GIT_CONFIG_* を使うユーザーの remote/auth フローを壊さない
  • 既存の env ベース挙動を保ったまま simple-git 3.36+ に追従できる

テスト観点

  • PAGER / GIT_PAGER / EDITOR を設定した shell で desktop の Git タブ / worktree 作成 / 削除が通る
  • GIT_SSH_COMMAND を使う remote で fetch / push / clone が通る
  • GIT_ASKPASS / SSH_ASKPASS を使う認証フローが通る
  • GIT_CONFIG_GLOBAL / GIT_CONFIG_COUNT を使う環境で author / clone / fetch 挙動が変わらない
  • host-service の clone / import / workspace creation が通る

ユーザーのシェル環境に PAGER や EDITOR 等が設定されていると、
simple-git 3.36+ の block-unsafe-operations プラグインが
`Use of "PAGER" is not permitted without enabling allowUnsafePager`
を投げて、ワークスペースの削除・worktree 操作等がすべて失敗する。

upstream v1.5.5 の同梱 simple-git が 3.36.0 に上がった結果、
`PAGER=less` をログインシェルで設定しているユーザーで発生していた。

simple-git が弾く env キー (PAGER/EDITOR/GIT_* 系) は
このアプリの git 操作では不要なので、env に詰める前に除外する。
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

Warning

Rate limit exceeded

@MocA-Love has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 11 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 45 minutes and 11 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1e89aa79-973c-4b37-b69e-23a78311c813

📥 Commits

Reviewing files that changed from the base of the PR and between e6df4e6 and ab78b34.

📒 Files selected for processing (9)
  • apps/desktop/src/lib/trpc/routers/projects/projects.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git-client.ts
  • packages/host-service/src/runtime/git/git.ts
  • packages/host-service/src/runtime/git/simple-git.ts
  • packages/host-service/src/trpc/router/project/project.ts
  • packages/host-service/src/trpc/router/workspace-creation/workspace-creation.ts
  • packages/host-service/src/trpc/router/workspace/workspace.ts
  • packages/shared/package.json
  • packages/shared/src/simple-git-unsafe.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/simple-git-pager-env

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8d0c976a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts Outdated
@MocA-Love MocA-Love changed the title fix(desktop): simple-git 3.36+ の PAGER env ブロックを回避 fix(git): preserve env-backed simple-git behavior Apr 18, 2026
@MocA-Love MocA-Love merged commit 373682c into main Apr 18, 2026
12 of 14 checks passed
MocA-Love added a commit that referenced this pull request Apr 18, 2026
MocA-Love added a commit that referenced this pull request Apr 18, 2026
Revert #323: simple-git unsafe env 対応を差し戻し
MocA-Love added a commit that referenced this pull request Apr 18, 2026
…#330)

* fix(desktop): simple-git 3.36+ の PAGER env ブロックを回避

ユーザーのシェル環境に PAGER や EDITOR 等が設定されていると、
simple-git 3.36+ の block-unsafe-operations プラグインが
`Use of "PAGER" is not permitted without enabling allowUnsafePager`
を投げて、ワークスペースの削除・worktree 操作等がすべて失敗する。

upstream v1.5.5 の同梱 simple-git が 3.36.0 に上がった結果、
`PAGER=less` をログインシェルで設定しているユーザーで発生していた。

simple-git が弾く env キー (PAGER/EDITOR/GIT_* 系) は
このアプリの git 操作では不要なので、env に詰める前に除外する。

* fix(git): preserve env-backed simple-git behavior

* fix(git): address PR CI failures
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