Skip to content

fix(install): resolve '+' version in env.jsonc for env capsules#10154

Merged
davidfirst merged 6 commits intomasterfrom
fix-plus-version-in-env-capsules
Jan 13, 2026
Merged

fix(install): resolve '+' version in env.jsonc for env capsules#10154
davidfirst merged 6 commits intomasterfrom
fix-plus-version-in-env-capsules

Conversation

@davidfirst
Copy link
Copy Markdown
Member

@davidfirst davidfirst commented Jan 13, 2026

When generating .bit_roots package.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 --pattern and bit sign when the env uses + for peer dependency versions.

Root cause: _getEnvDependencies() reads from selfPolicy (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 workspaceDeps to _getEnvDependencies() and use it to resolve + version placeholders, following the same pattern as WorkspaceManifest._resolvePlusVersions.

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.
Copilot AI review requested due to automatic review settings January 13, 2026 18:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 use snapToSemver for 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.

Copilot AI review requested due to automatic review settings January 13, 2026 19:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Copilot AI review requested due to automatic review settings January 13, 2026 21:50
@davidfirst
Copy link
Copy Markdown
Member Author

Addressed Copilot review comments:

  1. Test comment (line 349): Applied the suggestion - changed 'workspace/bitmap' to 'workspace dependencies'.

  2. install.main.runtime.ts (lines 965-971): The approach was intentionally changed after discovering that using getDependencies(envComponent) had unintended side effects - it imports the env component into the scope, causing test failures (components-index test expected 1 component but found 2). The current approach using workspaceDeps follows the same pattern as WorkspaceManifest._resolvePlusVersions and avoids these side effects. Updated the PR description accordingly.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +967 to +970
// Resolve "+" version placeholders using workspace dependencies
// Similar to WorkspaceManifest._resolvePlusVersions
if (version === '+') {
version = workspaceDeps[dependencyId] || '*';
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@davidfirst davidfirst enabled auto-merge (squash) January 13, 2026 21:55
@davidfirst davidfirst merged commit 818e959 into master Jan 13, 2026
12 checks passed
@davidfirst davidfirst deleted the fix-plus-version-in-env-capsules branch January 13, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants