Skip to content

fix(setup): stabilize Claude Code Homebrew path - #713

Open
barbatdev wants to merge 4 commits into
Gentleman-Programming:mainfrom
barbatdev:fix/claude-code-homebrew-path
Open

fix(setup): stabilize Claude Code Homebrew path#713
barbatdev wants to merge 4 commits into
Gentleman-Programming:mainfrom
barbatdev:fix/claude-code-homebrew-path

Conversation

@barbatdev

@barbatdev barbatdev commented Aug 12, 2026

Copy link
Copy Markdown

🔗 Linked Issue

Closes #461


🏷️ PR Type

  • type:bug — Bug fix
  • type:feature — New feature
  • type:docs — Documentation only
  • type:refactor — Code refactoring (no behavior change)
  • type:chore — Maintenance, dependencies, tooling
  • type:breaking-change — Breaking change

📝 Summary

  • Reuses the canonical Engram executable-path resolution when writing Claude Code's user MCP config.
  • Maps versioned Homebrew/Linuxbrew Cellar executables to the stable <brew-prefix>/bin/engram symlink.
  • Adds regression coverage for the Claude Code setup path and the single-executable-result contract.

📂 Changes

File Change
internal/setup/setup.go Shares canonical executable-path resolution with Claude Code setup while preserving its strict executable lookup error contract.
internal/setup/setup_test.go Covers Cellar-to-stable-symlink mapping, missing-symlink fallback, non-Cellar paths, and single-result canonicalization.

🧪 Test Plan

  • Unit tests pass locally: go test ./...
  • E2E tests pass locally: go test -tags e2e ./internal/server/...
  • Manually tested the affected functionality

Manual verification used an isolated fake Homebrew Cellar and isolated HOME; engram setup claude-code wrote the stable <brew-prefix>/bin/engram command and no versioned /Cellar/engram/ path.


🤖 Automated Checks

These run automatically and all must pass before merge:

Check What it verifies Status
Check Issue Reference PR body contains Closes #N / Fixes #N / Resolves #N
Check Issue Has status:approved Linked issue has status:approved label
Check PR Has type: Label* PR has exactly one type:* label
Unit Tests go test ./... passes
E2E Tests go test -tags e2e ./internal/server/... passes

✅ Contributor Checklist

  • I linked an approved issue above (Closes #461)
  • I added exactly one type:* label to this PR
  • I ran unit tests locally: go test ./...
  • I ran e2e tests locally: go test -tags e2e ./internal/server/...
  • Docs updated (not required; this restores the existing stable-path contract)
  • Commits follow conventional commits format
  • No Co-Authored-By trailers in commits

💬 Notes for Reviewers

PR #499 fixed the same Homebrew Cellar failure for the shared Codex/OpenCode/Gemini path. Claude Code still used its own direct symlink resolution and therefore kept writing the versioned Cellar target. This change routes both paths through one canonicalization helper without changing each caller's existing executable-lookup error policy.

The canonical resolver retains its existing fallback to bare engram when a Cellar path is detected but the stable Homebrew symlink is missing; this edge case is covered explicitly.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Claude Code MCP configuration to use stable Homebrew executable paths.
    • Added fallback handling when stable Homebrew symlinks are unavailable.
    • Ensured executable path resolution remains reliable across versioned Homebrew installations.
    • Prevented configuration from relying on PATH-dependent commands.
  • Tests

    • Added regression coverage for Homebrew path canonicalization and fallback behavior.
    • Added Windows-specific setup coverage for absolute executable paths.
    • Added automated Windows setup testing to continuous integration.

@barbatdev barbatdev added the type:bug Bug fix label Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 63b1bf68-517f-4560-bb29-d90522a010fd

📥 Commits

Reviewing files that changed from the base of the PR and between 6d25c22 and 7ff28ae.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

📝 Walkthrough

Walkthrough

The change centralizes Engram executable canonicalization for Claude Code MCP configuration and executable resolution. It adds Homebrew Cellar path normalization, absolute-path fallback handling, Windows validation, and regression tests.

Changes

Homebrew command canonicalization

Layer / File(s) Summary
Centralize executable canonicalization
internal/setup/setup.go
writeClaudeCodeUserMCP and resolveEngramCommand now use canonicalEngramCommand. Absolute paths are preserved, and non-absolute results are rejected.
Validate canonicalization behavior
internal/setup/setup_test.go
Tests cover Homebrew paths, missing symlinks, non-Cellar paths, MCP configuration output, and avoidance of repeated executable discovery.
Validate Windows absolute paths
internal/setup/setup_windows_test.go, .github/workflows/ci.yml
A Windows-specific test verifies preservation of an absolute executable path. CI runs the test on windows-latest.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: gentleman-programming

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: stabilizing Claude Code paths for Homebrew installations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/setup/setup.go`:
- Line 868: The writeClaudeCodeUserMCP configuration must never persist the bare
“engram” fallback from canonicalEngramCommand; retain that fallback only in
resolveEngramCommand. When canonicalization cannot find the stable symlink,
return an error or preserve a valid absolute command path, and add a regression
test covering the missing-symlink case.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 57a83502-aed6-4001-b5b9-f63394a51ac9

📥 Commits

Reviewing files that changed from the base of the PR and between 509e676 and c55c7a8.

📒 Files selected for processing (2)
  • internal/setup/setup.go
  • internal/setup/setup_test.go

Comment thread internal/setup/setup.go Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 47-53: Update the Checkout and Set up Go steps in the workflow to
reference immutable full commit SHAs instead of version tags, and configure
Checkout with persist-credentials set to false. Preserve the existing Go version
and step behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ee2ad47d-5430-487c-8488-5030c1884e93

📥 Commits

Reviewing files that changed from the base of the PR and between 8ac33d1 and 6d25c22.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • internal/setup/setup_windows_test.go

Comment thread .github/workflows/ci.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

engram setup writes versioned Cellar path, breaking MCP on brew upgrade (recurrence of #143)

2 participants