fix(setup): avoid baking versioned Homebrew Cellar path into MCP configs#499
Conversation
resolveEngramCommand() used os.Executable() + filepath.EvalSymlinks(), which resolves the engram symlink down to a versioned Homebrew/Linuxbrew Cellar path (e.g. .../Cellar/engram/1.16.1/bin/engram). That path is removed on the next 'brew upgrade', so OpenCode/Codex fail to spawn the engram MCP server with ENOENT. On Linux os.Executable() reads /proc/self/exe which is already fully resolved, so dropping EvalSymlinks alone does not help. When the resolved executable points into a versioned Cellar directory, map it to the stable <brew-prefix>/bin/engram symlink that brew keeps current, falling back to bare "engram" when that symlink is missing. Non-Cellar absolute paths are preserved unchanged. Relates to Gentleman-Programming/gentle-ai#863
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesStable Homebrew symlink resolution in setup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes engram setup generating MCP client configs that embed a versioned Homebrew/Linuxbrew Cellar path to the engram binary (which becomes stale after brew upgrade). It detects versioned .../Cellar/engram/<version>/bin/engram executables and maps them back to the stable <brew-prefix>/bin/engram symlink (or falls back when missing), so MCP registrations keep working across upgrades.
Changes:
- Updated
resolveEngramCommand()to translate versioned Homebrew/Linuxbrew Cellar paths to the stable<brew-prefix>/bin/engramsymlink. - Added
stableHomebrewEngramCommand()helper to encapsulate Cellar detection/mapping logic. - Added a table-driven test covering linuxbrew/macOS (arm/intel) Cellar mappings, missing-symlink fallback, and non-Cellar preservation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
internal/setup/setup.go |
Maps resolved versioned Homebrew/Linuxbrew Cellar paths back to the stable brew bin/engram symlink when generating MCP commands. |
internal/setup/setup_test.go |
Adds coverage to prevent regressions where versioned Cellar paths are baked into generated MCP configurations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if got := resolveEngramCommand(); got != tc.want { | ||
| t.Fatalf("resolveEngramCommand() = %q, want %q", got, tc.want) | ||
| } |
resolveEngramCommand returns OS-native separators via filepath.FromSlash, so compare with filepath.ToSlash to keep the table test green on Windows runners. Addresses PR review feedback.
Closes #498
Type
Bug fix (
type:bug)Summary
resolveEngramCommand()no longer bakes a versioned Homebrew/Linuxbrew Cellar path (e.g..../Cellar/engram/1.16.1/bin/engram) into MCP client configs.<brew-prefix>/bin/engramsymlink (which brew keeps current), falling back to bareengramwhen that symlink is missing.Why
After
brew upgrade engramthe old Cellar version directory is removed, so OpenCode/Codex fail to spawn the engram MCP server withENOENT: posix_spawn. On Linuxos.Executable()reads/proc/self/exe, which is already fully resolved to the Cellar path, so droppingEvalSymlinksalone does not help — the Cellar path must be explicitly detected and mapped back to the stable symlink.Changes
internal/setup/setup.gostableHomebrewEngramCommand; map versioned Cellar paths to the stable brew bin symlink; corrected doc commentinternal/setup/setup_test.goTestResolveEngramCommandHomebrewCellar(linuxbrew, macOS arm/intel, missing-symlink fallback, non-Cellar preserved)Test Plan
go build ./...go test ./internal/setup/— all pass, including existingTestResolveEngramCommandContext
Originally reported against gentle-ai (Gentleman-Programming/gentle-ai#863), but gentle-ai already migrates Cellar paths in
opencode.jsonand never writesopencode.jsonc. The real source of the versioned path is engram setup, fixed here.Checklist
type:*labelCo-Authored-BytrailersSummary by CodeRabbit
Bug Fixes
.../bin/engramsymlink when the resolved executable previously pointed to a versioned Cellar location.