Skip to content

fix(plugin): git_clone でシェル CWD 削除時の失敗を回避#16

Merged
takemi-ohama merged 1 commit into
mainfrom
fix/plugin-update-cwd-resilient
May 21, 2026
Merged

fix(plugin): git_clone でシェル CWD 削除時の失敗を回避#16
takemi-ohama merged 1 commit into
mainfrom
fix/plugin-update-cwd-resilient

Conversation

@takemi-ohama
Copy link
Copy Markdown
Contributor

Summary

  • devbase plugin update 実行時、シェルのカレントディレクトリが削除された状態で getcwd() が ENOENT を返すと、git_clone() 内の subprocess.run(['git', 'clone', ...]) が無効な CWD を継承し、git-remote-https ヘルパの起動で落ちていた
  • subprocess.run(..., cwd=str(dest.parent)) を明示し、Python (= 親シェル) の CWD に依存しないようにする
  • dest.parent.mkdir(parents=True, exist_ok=True) を追加し、cwd 用パスの存在を保証

再現エラー

Updating 'carmo-web' from https://github.com/volareinc/devbase-ext.git...
...
Error: Some plugins failed to update:
  - git clone failed for https://github.com/volareinc/devbase-ext.git: Cloning into '/var/folders/.../tmp.../repo'...
fatal: Unable to read current working directory: No such file or directory
fatal: remote helper 'https' aborted session

シェルが既に削除されたディレクトリ (carmo-system-console) に居る状態で devbase plugin update を実行すると、複数の git clone が同上で失敗する。

検証

import os, subprocess, tempfile
victim = tempfile.mkdtemp()
os.chdir(victim); os.rmdir(victim)   # シェル CWD 削除を再現

# 修正前 (cwd= 未指定): 失敗
#   fatal: Unable to read current working directory ...
#   fatal: remote helper 'https' aborted session

# 修正後 (cwd=dest.parent): 成功
#   ['.git', '.gitignore', 'LICENSE', 'README.md', 'adminer']

Test plan

  • 修正前ロジック (cwd= 未指定) で当該エラーが再現することをローカル確認
  • 修正後ロジック (cwd=str(dest.parent)) で同条件でも git clone が成功することを確認
  • 通常 CWD でも devbase plugin install / devbase plugin update が回帰しないこと (本リポジトリにはテストスイートが無いため目視)

🤖 Generated with Claude Code

シェルのカレントディレクトリが削除された状態で `devbase plugin update` を
実行すると、Python から `git clone` を呼ぶ際に無効な CWD を継承し、
git-remote-https ヘルパが起動時に getcwd() ENOENT で落ちていた:

  fatal: Unable to read current working directory: No such file or directory
  fatal: remote helper 'https' aborted session

`git_clone()` で subprocess.run() に `cwd=dest.parent` を明示し、
親プロセスの CWD に依存しないようにする。`dest.parent.mkdir(parents=True,
exist_ok=True)` で cwd 用ディレクトリの存在も保証する。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@takemi-ohama takemi-ohama merged commit aca7927 into main May 21, 2026
5 checks passed
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