Skip to content

fix: DevContainerプラグインインストールのパス計算を修正 - #181

Merged
keito4 merged 1 commit into
mainfrom
fix/plugin-installation-path
Dec 26, 2025
Merged

fix: DevContainerプラグインインストールのパス計算を修正#181
keito4 merged 1 commit into
mainfrom
fix/plugin-installation-path

Conversation

@keito4

@keito4 keito4 commented Dec 26, 2025

Copy link
Copy Markdown
Owner

問題

DevContainerを再ビルドしてもClaudeプラグインが表示されない問題がありました。

根本原因

  • setup-claude.sh/tmp/setup-claude.shから実行されるため、REPO_ROOT計算が失敗
  • SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/tmp
  • REPO_ROOT="$(dirname "$SCRIPT_DIR")"/
  • PLUGINS_FILE="${REPO_ROOT}/.claude/plugins/plugins.txt"/.claude/plugins/plugins.txt(存在しない)

その他の問題

  • || trueでエラーが隠蔽され、問題が表面化しない

変更内容

1. script/setup-claude.sh

変更前:

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
PLUGINS_FILE="${REPO_ROOT}/.claude/plugins/plugins.txt"

変更後:

# DevContainer内の固定パスを使用
PLUGINS_FILE="/home/vscode/.claude/plugins/plugins.txt"

2. .devcontainer/devcontainer.json

変更前:

"postCreateCommand": "... && /tmp/setup-claude.sh || true",

変更後:

"postCreateCommand": "... && /tmp/setup-claude.sh",

期待される動作

  • ✅ DevContainer起動時にプラグインが正しくインストールされる
  • ✅ エラー発生時にログで確認できる

Test plan

  • CI/CDでイメージビルドが成功することを確認
  • 新バージョン(v1.8.1)がリリースされることを確認
  • pulse_surveyで新イメージを使用してプラグインが表示されることを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Improved error reporting in development environment setup by preventing silent failures.
    • Fixed plugin file path resolution in the setup script.

✏️ Tip: You can customize this high-level summary in your review settings.

## 問題
- setup-claude.shが/tmp/setup-claude.shから実行されるため、REPO_ROOT計算が失敗
- PLUGINS_FILEが/.claude/plugins/plugins.txtとなり、ファイルが見つからずエラー
- || trueでエラーが隠蔽され、問題が表面化しない

## 変更内容
- script/setup-claude.sh: パス計算を絶対パス(/home/vscode/.claude/plugins/plugins.txt)に変更
- .devcontainer/devcontainer.json: || trueを削除してエラーを可視化

## 期待される動作
- DevContainer起動時にプラグインが正しくインストールされる
- エラー発生時にログで確認できる

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@keito4
keito4 merged commit e98ca4d into main Dec 26, 2025
3 of 4 checks passed
@coderabbitai

coderabbitai Bot commented Dec 26, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The changes improve error visibility in the DevContainer setup by removing error suppression from the postCreateCommand and hardcoding the plugins file path in the setup script from a dynamic location to a fixed absolute path.

Changes

Cohort / File(s) Summary
DevContainer Configuration
.devcontainer/devcontainer.json
Removed || true error suppression from postCreateCommand, allowing setup failures to propagate and fail the container initialization instead of being silently ignored.
Setup Script Path Resolution
script/setup-claude.sh
Changed PLUGINS_FILE from dynamic path derivation (based on script location) to hardcoded absolute path /home/vscode/.claude/plugins/plugins.txt, establishing a fixed location dependency for plugin discovery.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

released

Poem

🐰 Hoppy hop, errors now shine bright!
No more silent fails in the night,
Absolute paths guide plugins true,
Setup speaks loud—what's wrong, we'll review!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/plugin-installation-path

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af20777 and 5160873.

📒 Files selected for processing (2)
  • .devcontainer/devcontainer.json
  • script/setup-claude.sh

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.

@keito4
keito4 deleted the fix/plugin-installation-path branch December 26, 2025 02:59
@claude

claude Bot commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

プルリクエストレビュー

概要

DevContainer起動時のClaudeプラグインインストールが失敗する問題の修正を確認しました。根本原因の分析と修正アプローチは適切です。


✅ 良い点

  1. 根本原因の正確な特定

    • /tmp/setup-claude.sh実行時のパス計算問題を正確に把握
    • BASH_SOURCE[0]による相対パス解決の限界を理解した修正
  2. シンプルで効果的な解決策

    • DevContainer環境では固定パス/home/vscode/.claude/plugins/plugins.txtを使用
    • Dockerfileの78行目でplugins.txtが確実にコピーされることを活用
  3. エラーハンドリングの改善

    • || trueを削除してエラーを可視化
    • set -euo pipefailにより早期エラー検出が有効化
  4. Conventional Commits準拠

    • fix:タイプの使用が適切
    • semantic-releaseによる自動リリースがトリガーされる

⚠️ 改善提案

1. テストカバレッジの追加(優先度: 高)

現在のTest planは手動確認のみです。以下の自動テストを追加することを推奨します:

# .github/workflows/devcontainer-test.yml (新規)
name: DevContainer Test
on:
  pull_request:
    paths:
      - '.devcontainer/**'
      - 'script/setup-claude.sh'
      - '.claude/plugins/plugins.txt'

jobs:
  test-devcontainer:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build DevContainer
        run: |
          # DevContainer CLIを使用してビルドとpostCreateCommandの実行を検証
          docker build -t test-devcontainer .devcontainer
      - name: Verify plugins.txt location
        run: |
          docker run --rm test-devcontainer test -f /home/vscode/.claude/plugins/plugins.txt

2. スクリプトの堅牢性向上(優先度: 中)

script/setup-claude.sh:20のハードコードされたパスに対して、存在確認を強化できます:

# 現在
PLUGINS_FILE="/home/vscode/.claude/plugins/plugins.txt"

# 提案
PLUGINS_FILE="${PLUGINS_FILE:-/home/vscode/.claude/plugins/plugins.txt}"

# 存在確認の改善(既存のチェックを維持)
if [[ ! -f "$PLUGINS_FILE" ]]; then
    log_warn "plugins.txt が見つかりません: ${PLUGINS_FILE}"
    log_info "Dockerfileでのコピーが実行されているか確認してください"
    exit 0
fi

3. ドキュメントの更新(優先度: 低)

script/setup-claude.shの先頭コメントを更新して、/tmpから実行される前提を明記:

# ============================================================================
# Claude Code Setup Script
# DevContainer 起動時にプラグインをユーザースコープでインストールします
# 
# 注意: このスクリプトは postCreateCommand から /tmp/setup-claude.sh として実行されます
# そのため、PLUGINS_FILE は固定パス (/home/vscode/.claude/plugins/plugins.txt) を使用します
# ============================================================================

🔒 セキュリティチェック

  • ✅ 認証情報の露出なし
  • ✅ パスインジェクションのリスクなし(固定パス使用)
  • set -euo pipefailによるエラー伝播が有効

🎯 パフォーマンス

  • ✅ 変更による性能への影響なし
  • ✅ 相対パス計算の削除により、わずかな高速化

📋 CLAUDE.md 準拠チェック

  • ✅ Conventional Commits準拠(fix:タイプ)
  • ✅ Test plan記載あり(手動テスト)
  • ⚠️ 自動テストの追加を推奨(TDD原則の観点から)
  • ✅ PR本文が構造化されている(問題・変更内容・期待される動作)

総評

承認推奨

根本原因の分析と修正アプローチは適切です。|| trueの削除によりエラーの可視性が向上し、DevOps観点でも改善されています。

マージ前に以下の確認を推奨します:

  1. ✅ CI/CDパイプラインの成功
  2. ✅ semantic-releaseによるバージョンタグ生成(v1.8.1)
  3. 🔄 実環境(pulse_survey)での動作確認

オプション: テストカバレッジ向上のため、DevContainer自動テストの追加を検討してください。


🤖 レビュー実施: Claude Code (Sonnet 4.5)

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.8.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant