fix(git): サンドボックス内 git push の credential 警告2件を抑制 - #303
Merged
Conversation
Claude Code のネイティブサンドボックス内で git push 等を実行すると、 HTTP プロキシ(localhost:<ランダムポート>)向けの credential store が GCM 経由でキーチェーンに書き込もうとして失敗し、毎回 stderr に warning: failed to probe 'http://localhost:<port>/' to detect provider warning: Permission denied (localhost:<port>) fatal: Could not create new item [0x186a1] が出ていた(git 自体は成功し終了コードは 0)。 credential.helper をラッパースクリプトに差し替え、ループバック宛の リクエストだけ黙って捨てて、それ以外は従来どおり GCM へ委譲する。 credential.<url>.helper はポートを省略したパターンがポート付きホストに マッチせず、プロキシのポートはセッションごとに変わるため、静的な gitconfig の URL 指定では除外できない(実測)。 検証: 対比ペアで確認済み。ラッパー適用時は stderr 無音、 GIT_CONFIG_GLOBAL=~/.gitconfig で無効化すると上記3行が再現する。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Claude Code のネイティブサンドボックス内で
git push/git fetch等を実行すると、毎回 stderr に以下が出ていたのを抑制する。git 自体は成功し終了コードは 0 だが、毎回のノイズになっていた。
根本原因
サンドボックスは
HTTP_PROXY=http://<user>:<pass>@localhost:<ランダムポート>を設定する。git はこのプロキシ認証を credential 機構経由で扱うため、通信成功後にcredential approveを発行し、GCM がstoreで呼ばれる。そこで GCM が:http://localhost:<port>/をプローブ → サンドボックスが接続を拒否 →warning: Permission denied (localhost:<port>)fatal: Could not create new item [0x186a1]修正内容
credential.helperをラッパースクリプトに差し替え、ループバック宛(localhost/127.0.0.1/[::1]、ポート有無問わず)のリクエストだけ黙って捨て、それ以外は従来どおり GCM へ委譲する。dot_config/git/executable_claude-code-credential-helper.sh(新規)dot_config/git/claude-code.inc—credential.helperを空値でリセットしてからラッパーを追加(多値キーなので、include で積まれた GCM と osxkeychain をリセットする必要がある)なぜラッパーが必要か
credential.<url>.helperはポートを省略したパターンがポート付きホストにマッチしない(実測:credential.http://localhost.helper=はhost=localhost:63229に効かない。完全一致のみ)。プロキシのポートはセッションごとに変わるため、静的な gitconfig の URL 指定では除外できない。なお、そもそもセッション限りのプロキシ資格情報をキーチェーンに永続化する必要はないため、捨てて問題ない。
検証
対比ペア(同一セッション、
GIT_CONFIG_GLOBALのみ差し替え):ラッパー単体:
host=localhost:1/host=127.0.0.1へのstore→ 無音・exit 0host=github.comへのget→ GCM へ委譲され資格情報が返る実際の
git push(サンドボックス有効のまま): github.com への認証を伴うため GCM のstoreを通るが、stderr クリーン・exit 0。localhost以外のホストでもキーチェーン警告が出ないことを確認済み。その他:
just lintexit 0 /chezmoi diff --source "$(pwd)"の差分は shfmt 整形分のみ。チェックリスト
GIT_CONFIG_GLOBALが設定されないため影響なし.incのコメントに記載マージ後の後始末(要手動)
この修正はもともと
mainに固定された chezmoi ソース worktree~/.local/share/chezmoiに未コミットのまま置かれていた。本 PR で取り込んだので、マージ後にそちらを掃除する:両方消さないと
git pullが拒否される。マージ前に実行すると次の apply でclaude-code.incが巻き戻り、いま効いている修正が無効化されるので順序に注意。🤖 Generated with Claude Code