Repository navigation
Harden Windows Pester install against missing PSGallery - #6892
Merged
Merged
Conversation
The setup.ps1 unit-tests job intermittently fails on the windows-latest runner with 'No repository with the name PSGallery was found.' when the default PowerShell Gallery is not registered, so Set-PSRepository throws before Pester can be installed. Register the default gallery first when it is missing, then set its policy and install Pester as before.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Contributor
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
This was referenced Jul 22, 2026
danielhanchen
added a commit
to shimmyshimmer/unsloth-staging-4
that referenced
this pull request
Aug 2, 2026
…ailure The setup.ps1 Pester job has now broken twice on PRs that touch no PowerShell. unslothai#6892 added a guard for PSGallery being absent from the runner's repository list, but called Register-PSRepository -Default with -ErrorAction SilentlyContinue. On a runner where the legacy PackageManagement provider cannot bootstrap nuget.exe, that call fails with NuGet.Commands.CommandException: Missing option value for: '-source' silently, and the next line dies with the misleading "No repository with the name 'PSGallery' was found" from the original bug, so the log points at the wrong cause. Changes: - Prefer PSResourceGet, which resolves PSGallery over HTTPS and never shells out to nuget.exe. Keep Install-Module as a fallback for images without it. - Skip the network entirely when the image already ships a new enough Pester. - Stop silencing the registration, so the real error reaches the log. - Retry with backoff, swapping install client between attempts when both are available. PSGallery has served 500s to PSResourceGet while Install-Module kept working, so retrying one client three times does not survive that. - Verify the module actually imported instead of assuming the install worked. Add tests/studio/test_pester_bootstrap_hardening.py, which parses the workflow and fails if the registration is silenced again, if PSResourceGet stops being preferred, or if the retry, client swap or verification are dropped. Restoring the previous bootstrap fails 6 of its 7 tests. Verified with pwsh 7.6 and PSResourceGet 1.2.0: the step extracted from the workflow parses and installs Pester, the setup.ps1 suite runs against it, a forced nuget failure retries and rethrows the real error, and a simulated PSGallery 500 against PSResourceGet recovers via Install-Module.
danielhanchen
added a commit
that referenced
this pull request
Aug 2, 2026
…ry failure (#7743) * Harden the Windows Pester bootstrap against the nuget.exe PSGallery failure The setup.ps1 Pester job has now broken twice on PRs that touch no PowerShell. #6892 added a guard for PSGallery being absent from the runner's repository list, but called Register-PSRepository -Default with -ErrorAction SilentlyContinue. On a runner where the legacy PackageManagement provider cannot bootstrap nuget.exe, that call fails with NuGet.Commands.CommandException: Missing option value for: '-source' silently, and the next line dies with the misleading "No repository with the name 'PSGallery' was found" from the original bug, so the log points at the wrong cause. Changes: - Prefer PSResourceGet, which resolves PSGallery over HTTPS and never shells out to nuget.exe. Keep Install-Module as a fallback for images without it. - Skip the network entirely when the image already ships a new enough Pester. - Stop silencing the registration, so the real error reaches the log. - Retry with backoff, swapping install client between attempts when both are available. PSGallery has served 500s to PSResourceGet while Install-Module kept working, so retrying one client three times does not survive that. - Verify the module actually imported instead of assuming the install worked. Add tests/studio/test_pester_bootstrap_hardening.py, which parses the workflow and fails if the registration is silenced again, if PSResourceGet stops being preferred, or if the retry, client swap or verification are dropped. Restoring the previous bootstrap fails 6 of its 7 tests. Verified with pwsh 7.6 and PSResourceGet 1.2.0: the step extracted from the workflow parses and installs Pester, the setup.ps1 suite runs against it, a forced nuget failure retries and rethrows the real error, and a simulated PSGallery 500 against PSResourceGet recovers via Install-Module. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Close three vacuity gaps in the Pester bootstrap guard The guard passed under mutations it was meant to catch: - matching the bare string Install-PSResource hit the Get-Command probe, so deleting the install branch left the ordering assertion satisfied - deleting both registration commands left the silencing loop with no lines to inspect, so it passed on an unregistered-PSGallery runner - no pytest workflow filters on studio-windows-inference-smoke.yml, so a workflow-only edit never ran the guard at all Assert the invocation and the initial client choice, require both registration commands to be present, and run the guard from the pester job itself, which is the only job a workflow-only edit triggers. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.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.
Problem
The
setup.ps1 unit tests (VS 2026 / CMake guard)job in this workflow intermittently fails on thewindows-latestrunner at theInstall Pester v5step:The default PowerShell Gallery is occasionally not registered on GitHub's hosted Windows runners.
Set-PSRepositoryonly modifies an already-registered repository, so it throws before Pester can be installed and the whole job fails, even though nothing in the change under test is at fault.Fix
Re-register the default gallery when it is missing, before setting its policy and installing Pester:
Register-PSRepository -Defaultrecreates the built-in PSGallery entry, so the subsequentSet-PSRepositoryandInstall-Modulealways have a repository to target. When PSGallery is already present (the common case) the guard is a no-op, so behavior is unchanged on healthy runners. This is the standard remedy for the "No repository with the name 'PSGallery' was found" error on hosted runners.Only the
Install Pester v5step is touched; the smoke jobs and Pester suite are unchanged.