fix(ci): pin PSDepend to 0.4.1 to fix PowerShell 5.1 bootstrap#471
Merged
Conversation
build.ps1 -Bootstrap failed on Windows PowerShell 5.1 with:
PSDepend\0.3.8\Private\SemanticVersion.ps1: Cannot add type.
The type name 'System.Management.Automation.SemanticVersion'
already exists.
PSDepend 0.3.8 ships an unguarded Add-Type for its PS5.1
SemanticVersion polyfill (`if ($PSVersionTable.PSVersion.Major -lt 6)`).
On PS5.1 the type isn't built in, so when PSDepend is imported a second
time in the same session — as happens during bootstrap when PSDepend is
listed as a dependency of itself — the second Add-Type throws because
the type already exists. PS6+ is unaffected since the type is built in
and the guard short-circuits.
PSDepend 0.4.1 adds the missing existence guard
(`-and -not ('System.Management.Automation.SemanticVersion' -as [type])`),
making the polyfill idempotent. Bump the pin to 0.4.1.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
Run Tests (PowerShell 5.1)CI job has been failing on every PR (e.g. #468, #469, #470) duringbuild.ps1 -Bootstrapwith:Root cause
PSDepend
0.3.8ships an unguardedAdd-Typefor its Windows PowerShell 5.1SemanticVersionpolyfill:On PS 5.1,
System.Management.Automation.SemanticVersionis not a built-in type, so this runs. When PSDepend is imported a second time in the same session — which the bootstrap triggers because PSDepend is pinned as a dependency of itself inrequirements.psd1— theAdd-Typethrows, since the type already exists in the AppDomain. PowerShell 6+ is unaffected: the type is built in, so the guard short-circuits.PSDepend
0.4.1(newly released) adds the missing existence guard, making the polyfill idempotent:Fix
Bump the PSDepend pin in
requirements.psd1from0.3.8→0.4.1.Reproduction / verification
Reproduced on local Windows PowerShell 5.1 (
5.1.26100) by pre-defining the type then dot-sourcing each version'sSemanticVersion.ps1:0.3.8Cannot add type. The type name 'System.Management.Automation.SemanticVersion' already exists.0.4.1Add-Type)CI will confirm the PS 5.1 job goes green on this PR.
🤖 Generated with Claude Code