Skip to content

fix: プラグインインストール時の claude コマンド PATH 解決を改善 - #634

Merged
keito4 merged 1 commit into
mainfrom
fix/plugin-install-claude-path
Mar 23, 2026
Merged

fix: プラグインインストール時の claude コマンド PATH 解決を改善#634
keito4 merged 1 commit into
mainfrom
fix/plugin-install-claude-path

Conversation

@keito4

@keito4 keito4 commented Mar 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Docker ビルド時に root ユーザーで実行される install-claude-plugins.shclaude コマンドが見つからない問題を修正

Why

Dockerfile の ENV PATH は設定されているが、--mount=type=secret を使う RUN ステップで PATH が正しく引き継がれないケースがあり、claude: command not found でプラグインインストールが 15 件すべて失敗していた。

What

  1. PATH フォールバックの -d (ディレクトリ存在) チェックを削除し、常に PATH に追加
  2. claude コマンドが見つからない場合、find で探索して PATH に追加するフォールバックを追加
  3. バイナリが完全に見つからない場合はスキップして正常終了

Test plan

  • docker-image.yml ビルドでプラグインが正常にインストールされること
  • ビルドログに Claude version: x.x.x が表示されること

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved Claude CLI detection with enhanced fallback search and location handling
    • Better error messaging when Claude CLI is unavailable
  • Chores

    • Updated installation script path setup logic for more reliable plugin installation initialization

- PATH フォールバックのディレクトリ存在チェックを削除し、常に追加
- claude コマンドが見つからない場合に find で探索して PATH に追加
- root ユーザーで実行される Docker ビルド時に PATH が通らない問題を修正

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 23, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The script now unconditionally prepends Claude binary directories to PATH and implements smarter binary detection logic. It checks if claude exists on PATH first; if not, it searches predefined locations, updates PATH accordingly, and gracefully exits if the binary cannot be found.

Changes

Cohort / File(s) Summary
Claude Plugin Installer PATH & Detection Logic
script/install-claude-plugins.sh
Removed directory existence check before PATH manipulation; now unconditionally prepends binary directories. Refactored CLI detection to check command availability before running claude --version, with fallback binary search in /home/vscode/.claude/local/bin and /usr/local/bin. Changed version log fallback from 'not found' to 'unknown'.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

released

Poem

🐰 A rabbit hops through PATH so bright,
Finding Claude with logic tight,
No checks for dirs, just bold and free,
Binary search works gracefully,
Unknown not found—we're ready to go!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: improving claude command PATH resolution during plugin installation, which directly addresses the core issue being fixed.
Description check ✅ Passed The description includes all required sections (Summary, Why, What) with clear context about the problem, root cause, and specific changes made, though the Test plan checkboxes are incomplete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/plugin-install-claude-path

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 self-assigned this Mar 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0915f67fda

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

log_warn "claude コマンドが PATH に見つかりません"
log_info "PATH: $PATH"
# which で探索してパスを特定
CLAUDE_BIN=$(find /home/vscode/.claude/local/bin /usr/local/bin -name claude -type f 2>/dev/null | head -1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle missing dirs in claude binary discovery

With set -euo pipefail, the command substitution CLAUDE_BIN=$(find ... | head -1) aborts the script when any search root is missing (for example /home/vscode/.claude/local/bin before Claude is installed), because find returns non-zero and pipefail propagates it. That means execution can stop before the if [[ -n "$CLAUDE_BIN" ]] check, so the new fallback path fails in the exact environment it was meant to recover.

Useful? React with 👍 / 👎.

export PATH="${CLAUDE_BIN_DIR}:${PATH}"
else
log_warn "claude バイナリが見つかりません。プラグインインストールをスキップします。"
exit 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove credentials before early successful exit

The new exit 0 branch returns before the final cleanup step, but credentials have already been written to ${CLAUDE_DIR}/.credentials.json earlier in the script. If claude is not found, the build now succeeds while leaving auth material on disk, which can bake secrets into the resulting image.

Useful? React with 👍 / 👎.

@claude

claude Bot commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

コードレビュー

概要

install-claude-plugins.sh の PATH 解決改善。問題の根本原因(Docker --mount=type=secret ステップで PATH が引き継がれない)に対して適切なアプローチを取っています。


良い点

  • -d チェックを削除して常に PATH に追加する変更は、存在しないディレクトリを追加しても害がないため合理的
  • find フォールバックで /home/vscode/.claude/local/bin/usr/local/bin の2箇所を探索するのは網羅的
  • バイナリが見つからない場合に exit 1 ではなく exit 0 でスキップするのは Docker ビルドを壊さない設計として適切

指摘事項

[minor] find の探索パスが固定

CLAUDE_BIN=$(find /home/vscode/.claude/local/bin /usr/local/bin -name claude -type f 2>/dev/null | head -1)

${HOME} を使わずにハードコードしている一方、上の PATH フォールバックループでは ${HOME}/.claude/local/bin も考慮しています。root ユーザーで実行した場合 HOME=/root となるため、/root/.claude/local/bin が探索対象から漏れます。

提案:

CLAUDE_BIN=$(find "/home/vscode/.claude/local/bin" "${HOME}/.claude/local/bin" /usr/local/bin \
    -name claude -type f 2>/dev/null | sort -u | head -1)

ただし sort -u で重複パスを除外する必要があります(HOME=/home/vscode の場合に同一パスが重複するため)。

[minor] コメントに which への言及

# which で探索してパスを特定

実際のコードは find を使っており、which は使っていません。コメントが実装と一致していないため修正が望ましいです。


セキュリティ・パフォーマンス

特段の懸念なし。find の探索範囲が限定されており、head -1 で最初のマッチのみ取得するため問題ない範囲です。


CI ステータス

すべてのチェックがパス済み ✅ (claude-review / CodeRabbit は進行中)


総評: 実用的な修正で、主要な問題は解決されています。上記2点はオプションの改善提案です。マージ可能な状態です。

@keito4
keito4 merged commit 6b7f97d into main Mar 23, 2026
19 of 20 checks passed
@keito4
keito4 deleted the fix/plugin-install-claude-path branch March 23, 2026 06:22
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.106.2 🎉

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