fix(upgrade): fallback to --legacy-peer-deps on npm ERESOLVE error during OpenCode plugin upgrades#977
Conversation
…ring OpenCode plugin upgrades When upgrading OpenCode plugins via npm, conflicting peer dependencies in upstream packages can cause npm to fail with an ERESOLVE error. This change catches ERESOLVE errors during npm plugin upgrades and automatically retries the command with --legacy-peer-deps, resolving issue Gentleman-Programming#831. Closes Gentleman-Programming#831
|
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
npm ERESOLVE retry
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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
🤖 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/update/upgrade/strategy.go`:
- Around line 154-159: The npm retry path in strategy.go can still start after
the caller has already cancelled the operation. Re-check ctx with a ctx.Done()
guard immediately before constructing and launching the fallback install in the
npm/ERESOLVE branch inside the upgrade strategy logic, so the retry path exits
early instead of continuing work after cancellation.
🪄 Autofix (Beta)
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: 39bbc4e7-753c-4d96-89f8-0c49bfdd0c35
📒 Files selected for processing (2)
internal/update/upgrade/strategy.gointernal/update/upgrade/strategy_test.go
Summary
Closes #831
Adds automatic fallback to
--legacy-peer-depswhen an OpenCode plugin upgrade fails due to an npmERESOLVEpeer dependency conflict.Problem
When running
gentle-ai upgradefor OpenCode plugins (such asopencode-sdd-engram-manageoropencode-subagent-statusline), npm 7+ enforces strict peer dependency checks. Upstream peer conflicts (e.g., between@opentui/keymapand@opentui/solid) causenpm installto fail withERESOLVE could not resolve, leaving the plugin in a failed upgrade state.Solution
In
internal/update/upgrade/strategy.go, whennpmreturns an execution error during plugin upgrade:ERESOLVEor--legacy-peer-deps.--legacy-peer-depsappended (npm install --save --no-audit --no-fund --legacy-peer-deps ...).TestRunStrategyOpenCodePluginNpmERESOLVERetriesWithLegacyPeerDepsinstrategy_test.goto verify the retry flow.Test Plan
go test ./internal/update/upgrade/... -run TestRunStrategyOpenCodePluginNpmERESOLVERetriesWithLegacyPeerDeps— unit test passes.go build ./...— builds cleanly.Summary by CodeRabbit