fix(install): resolve '+' version in env.jsonc for env capsules#10154
fix(install): resolve '+' version in env.jsonc for env capsules#10154davidfirst merged 6 commits intomasterfrom
Conversation
When generating .bit_roots package.json for env capsules, the '+' version placeholder from env.jsonc was passed directly to pnpm, causing "isn't supported by any available resolver" errors. The fix resolves '+' by looking up the already-resolved version from the env component's dependencies (via getDependencies), leveraging the existing resolution infrastructure in apply-overrides.
There was a problem hiding this comment.
Pull request overview
This pull request fixes a bug where the '+' version placeholder from env.jsonc was being passed directly to pnpm during env capsule generation, causing "isn't supported by any available resolver" errors. This affected bit lane import --pattern and bit sign commands.
Changes:
- Modified
_getEnvDependencies()to resolve '+' versions by looking up already-resolved dependencies from the env component - Enhanced
_getDefaultPeerDependencies()to usesnapToSemverfor converting hash versions to valid semver format - Added comprehensive E2E test case to verify '+' version resolution during lane import operations
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| scopes/workspace/install/install.main.runtime.ts | Added logic to resolve '+' version placeholders by fetching the env component and looking up resolved versions from its dependencies, with fallback to '*' |
| scopes/dependencies/dependency-resolver/manifest/workspace-manifest-factory.ts | Added snapToSemver call to properly convert hash-based versions to semver format when resolving '+' placeholders |
| e2e/harmony/lanes/lane-import.e2e.ts | Added E2E test that creates an env with '+' version for peer dependency, then imports a lane to verify the version is properly resolved |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Addressed Copilot review comments:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Resolve "+" version placeholders using workspace dependencies | ||
| // Similar to WorkspaceManifest._resolvePlusVersions | ||
| if (version === '+') { | ||
| version = workspaceDeps[dependencyId] || '*'; |
There was a problem hiding this comment.
The comment could be more specific about what workspaceDeps contains. Consider clarifying that workspaceDeps contains workspace protocol references (e.g., 'workspace:*' for pnpm) rather than actual semver versions. This helps future maintainers understand why we're using it directly instead of looking up component versions.
When generating
.bit_rootspackage.json for env capsules during installation, the+version placeholder from env.jsonc was being passed directly to pnpm, causing "isn't supported by any available resolver" errors.This affected
bit lane import --patternandbit signwhen the env uses+for peer dependency versions.Root cause:
_getEnvDependencies()reads fromselfPolicy(raw env.jsonc values) and passes them directly without resolving+placeholders. Previous fixes (#9641, #10037) resolved+during dependency detection and manifest building, but this code path for env capsule generation was not covered.Fix: Pass
workspaceDepsto_getEnvDependencies()and use it to resolve+version placeholders, following the same pattern asWorkspaceManifest._resolvePlusVersions.