fix(devcontainer): DevContainerビルド時のClaudeプラグインインストールを改善 - #179
Conversation
## 変更内容 ### Dockerfile - プラグインインストール失敗時の明確な警告メッセージを追加 - ビルドログで問題を把握しやすくなりました ### devcontainer.json - postCreateCommand から --sync-only オプションを削除 - コンテナ起動時にプラグインも自動インストールされるように修正 ### script/post-create-plugins.sh (新規) - 不足しているプラグインを自動検出してインストールするスクリプトを追加 - コンテナ起動後のフォールバック用 ## 背景 ビルド時に BuildKit secret が提供されない場合、プラグインのインストールが 失敗していましたが、エラーが無視されていたため問題が表面化していませんでした。 この修正により: 1. ビルド時のエラーが明確になる 2. コンテナ起動時に自動的に再インストールを試みる 3. 手動インストールの方法も明示される 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughReplaces silent Dockerfile fallback with explicit Japanese warning/guidance on Claude plugin install failure, removes Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
script/post-create-plugins.sh (2)
22-28: Consider using parameter expansion for trimming whitespace.The use of
xargsto trim whitespace works but is unconventional. A more idiomatic bash approach would be:plugin="${line#"${line%%[![:space:]]*}"}" # Remove leading whitespace plugin="${plugin%"${plugin##*[![:space:]]}"}" # Remove trailing whitespaceOr even simpler with extended pattern matching:
shopt -s extglob plugin="${line##*([[:space:]])}" plugin="${plugin%%*([[:space:]])}"
19-40: Consider tracking already-installed plugins for complete visibility.Currently, the script only counts
installedandmissingplugins. Plugins that are already installed are silently skipped without any counter update, making it difficult to understand the complete picture of what happened during execution.🔎 Proposed enhancement to track skipped plugins
installed=0 +skipped=0 missing=0 while IFS= read -r line || [[ -n "$line" ]]; do # 空行とコメント行をスキップ [[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue # 前後の空白を除去 plugin=$(echo "$line" | xargs) [[ -z "$plugin" ]] && continue # プラグインがインストール済みかチェック if ! claude plugin list 2>/dev/null | grep -q "$plugin"; then echo "[INFO] インストール中: ${plugin}" if claude plugin install "$plugin" 2>/dev/null; then echo "[SUCCESS] 完了: ${plugin}" installed=$((installed + 1)) else echo "[WARN] スキップまたは失敗: ${plugin}" missing=$((missing + 1)) fi + else + echo "[INFO] 既にインストール済み: ${plugin}" + skipped=$((skipped + 1)) fi done < "$PLUGINS_FILE" if [[ $installed -gt 0 ]]; then echo "[SUCCESS] ${installed} 個のプラグインをインストールしました" fi +if [[ $skipped -gt 0 ]]; then + echo "[INFO] ${skipped} 個のプラグインは既にインストール済みです" +fi + if [[ $missing -gt 0 ]]; then echo "[WARN] ${missing} 個のプラグインのインストールに失敗しました" echo "[INFO] 手動でインストールするには: claude plugin install <plugin>@<marketplace>" fi
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.devcontainer/Dockerfile.devcontainer/devcontainer.jsonscript/post-create-plugins.sh
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/docker-image.yml : Build DevContainer images automatically with semantic versioning and multi-platform support in .github/workflows/docker-image.yml
🔇 Additional comments (4)
script/post-create-plugins.sh (2)
1-17: LGTM!The script header and file existence check are well-structured. The use of
set -euo pipefailprovides good error handling, and the graceful exit when the plugins file is missing is appropriate.
43-52: LGTM!The summary output and unconditional
exit 0are appropriate for a post-create hook. This ensures the DevContainer setup continues even if some plugins fail to install, while still providing useful diagnostic information to the user..devcontainer/Dockerfile (1)
84-88: LGTM! Improved error visibility during plugin installation.The updated fallback messaging clearly communicates when plugin installation fails and provides actionable guidance for users. The use of a subshell for the warning messages ensures the Docker build continues successfully while making the failure visible, which aligns perfectly with the PR objectives of improving error handling and auto-recovery.
The Japanese messages are appropriate for the target audience and consistent with the messaging in
post-create-plugins.sh..devcontainer/devcontainer.json (1)
49-49: Thesetup-claude.shchange is safe and correct.Verified:
- The script supports running without
--sync-only(defaults toSYNC_ONLY=false), enabling both config sync and plugin installation- Plugins are installed via
install_plugins()whenSYNC_ONLYis false, aligning with the PR objective for auto-installation at container startuppost-create-plugins.shprovides a compatible fallback mechanism that checks for missing plugins and installs only those not yet present, ensuring graceful recovery if the initial installation fails
| [[ -z "$plugin" ]] && continue | ||
|
|
||
| # プラグインがインストール済みかチェック | ||
| if ! claude plugin list 2>/dev/null | grep -q "$plugin"; then |
There was a problem hiding this comment.
Fix plugin existence check to use exact matching.
The current grep -q "$plugin" performs substring matching, which can produce false positives. For example, if the plugins list contains both "git" and "github", checking for "git" would incorrectly match "github".
🔎 Proposed fix using exact matching
- if ! claude plugin list 2>/dev/null | grep -q "$plugin"; then
+ if ! claude plugin list 2>/dev/null | grep -qE "^${plugin}(\s|$)"; thenAlternatively, use word boundary matching:
- if ! claude plugin list 2>/dev/null | grep -q "$plugin"; then
+ if ! claude plugin list 2>/dev/null | grep -qw "$plugin"; thenNote: The best approach depends on the exact output format of claude plugin list. You may need to verify the output format to ensure the pattern matches correctly.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if ! claude plugin list 2>/dev/null | grep -q "$plugin"; then | |
| if ! claude plugin list 2>/dev/null | grep -qw "$plugin"; then |
🤖 Prompt for AI Agents
In script/post-create-plugins.sh around line 31, the existence check uses grep
-q "$plugin" which does substring matching and can yield false positives (e.g.,
"git" matching "github"); change the check to an exact whole-line match such as
using grep -xF -q "$plugin" (or grep -wF -q "$plugin" if word boundaries are
needed) so the plugin name must match exactly, ensure the variable is quoted and
escaped appropriately, and if claude plugin list prints additional columns
adjust the pattern (or trim/parse the output) to match only the plugin name
field.
マージコンフリクトを解決: - BuildKit secret の権限指定(uid=0,gid=0)を維持 - エラーメッセージの改善を追加 - chown による所有権設定を維持
PR レビュー結果このPRはDevContainerビルド時のClaudeプラグインインストールの改善に関するもので、全体的に良い改善です。詳細なフィードバックを以下に提供します。 ✅ 良い点1. エラーハンドリングの改善
2. フォールバック戦略
3. --sync-only 削除の妥当性
|
|
🎉 This PR is included in version 1.6.6 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
概要
DevContainerビルド時のClaudeプラグインインストールを改善し、エラーハンドリングと自動リカバリーを強化しました。
変更内容
1. Dockerfile
2. devcontainer.json
postCreateCommandから--sync-onlyオプションを削除3. script/post-create-plugins.sh (新規)
背景
ビルド時に BuildKit secret が提供されない場合、プラグインのインストールが失敗していましたが、
|| trueにより エラーが無視されていたため問題が表面化していませんでした。この修正により:
テスト
関連Issue
プラグインインストールエラーの解決
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.