🩹 [Patch]: Ensure the selected GitHub module version is the one loaded#100
Open
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
Open
🩹 [Patch]: Ensure the selected GitHub module version is the one loaded#100Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
Conversation
…sions init.ps1 now resolves the exact installed version satisfying the Version input, removes any already-loaded GitHub module versions from the session, and imports the resolved version with -RequiredVersion -Global — so the user script uses the selected version instead of whatever PowerShell would auto-load from PSModulePath.
Copilot started reviewing on behalf of
Marius Storhaug (MariusStorhaug)
July 11, 2026 17:24
View session
There was a problem hiding this comment.
Pull request overview
This PR makes the GitHub PowerShell module import deterministic by resolving an installed version that matches the requested Version input, unloading any already-loaded GitHub module, and then importing the resolved version with -RequiredVersion so subsequent scripts in the action run against the intended module version.
Changes:
- Resolve the newest installed GitHub module version that satisfies the requested
Versionconstraint. - Remove any already-loaded GitHub module from the session before importing.
- Import the resolved version explicitly via
Import-Module -RequiredVersion ... -Force -Global.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+70
to
+82
| # Resolve the exact installed version that satisfies the request (newest match), so the loaded | ||
| # module is deterministic instead of whatever PowerShell would auto-load from PSModulePath. | ||
| $resolveParams = @{ | ||
| Name = $Name | ||
| ErrorAction = 'SilentlyContinue' | ||
| } | ||
| if ($Version) { | ||
| $resolveParams['Version'] = $Version | ||
| } | ||
| $resolved = Get-InstalledPSResource @resolveParams | Sort-Object Version -Descending | Select-Object -First 1 | ||
| if (-not $resolved) { | ||
| throw "No installed '$Name' version satisfies the requested version '$Version'." | ||
| } |
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.
Makes the GitHub module version selected through the
Version/Prereleaseinputs the version that is actually loaded and used by the script. Previouslyinit.ps1skipped importing whenever any version was already loaded, and when it did import it used an unconstrainedImport-Module— so PowerShell could auto-load a different (for example newer, preinstalled) version fromPSModulePath, defeating the requested pin.Fixed: the selected GitHub module version is the one loaded
init.ps1now resolves the exact installed version satisfying the request, removes any already-loaded GitHub module versions from the session, and imports the resolved version with-RequiredVersion … -Force -Global. Every subsequent command in the run (info.ps1, the user script,clean.ps1) uses the selected version.Technical Details
src/init.ps1: resolve the newest installed version matchingVersionviaGet-InstalledPSResource;Remove-Module -Forcebefore importing;Import-Module -RequiredVersion <resolved> -Force -Global. Fails fast if no installed version satisfies the requestedVersion.