Claude Plugin 安裝失敗:SSH vs HTTPS 問題
問題描述
執行 claude plugin install 或 claude plugin update 時出現以下錯誤:
fatal: could not read Username for 'https://gitlab.example.com': terminal prompts disabled
原因
Claude CLI 在 clone plugin 倉庫時,內部自行組出 HTTPS URL,忽略了 settings.json 中 marketplace 設定的 SSH URL,導致 Git 在非互動模式下無法提供帳密而失敗。
解法
透過 Git 的 insteadOf 設定,在 Git 層面攔截 HTTPS 請求並強制轉換為 SSH,繞過 CLI 內部行為。
1. 確認 SSH 連線正常
ssh -T [email protected]
應回應類似:Welcome to GitLab, @username!
2. 設定 Git insteadOf
git config --global url."[email protected]:".insteadOf "https://gitlab.example.com/"
3. 驗證設定
git config --global --get-all url."[email protected]:".insteadOf
# 應輸出:https://gitlab.example.com/
4. 重新安裝 Plugin
claude plugin install <plugin-name>@<marketplace>
備註
- 此設定為全域生效,對所有使用該 Git host 的操作均有效。
- 需確保本機已有對應的 SSH key 並已加入 GitLab。