PowerShell / PowerShellGetv2

PowerShellGet is the Package Manager for PowerShell
https://www.PowerShellGallery.com
MIT License
431 stars 138 forks source link

No retry of network connection if use -repository psgallery #90

Closed ghost closed 6 years ago

ghost commented 7 years ago

Using any of the PowerShellGet cmdlets, if -Repository PSGallery is specified and is unavailable due to network or similar issues, user must use a new console session for the command to succeed.

I was having networking issues could not reach the PowerShell Gallery using Find-Module from PowerShellGet v1.1.2.0. I specified -Repository PSGallery because I test with other galleries.

I received the error "PowerShell Gallery is currently unavailable. Please try again later." I used a browser, was eventually able to connect to the Gallery website.

After that, going back to the same PS session, I got the same message every time I re-ran the command. I tried opening a new PS Session and it worked. Turns out to be due to a perf optimization only for PSGallery, and only if the repository is specified.

Expected Behavior

When the request times out, and I repeat the command, it should try to connect again immediately. Re-running the command should be treated as a discrete occurrence, regardless of what Repo is specified. Networking & website connection errors happen intermittently for a variety of reasons.

Once the connection can be established, the command should work.

Current Behavior

These results can be reproduced by disconnecting network & wifi connections, then running two commands: Find-Module PowerShellGet Find-Module PowerShellGet -Repository PSGallery

The first will fail with an error message beginning " No match found". The second will fail with the error message "PowerShell Gallery is currently unavailable"

Reconnect the network, & repeat the 2 commands The first command will succeed. The second command will fail with the same error, indefinitely. Note that the module specified does not matter.

Possible Solution

There is a special check in place for when the user specifies using PSGallery as the PSRepository. This should be removed.

Context

Your Environment


> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.14393.693
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.693
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
> Get-Module -ListAvailable PowerShellGet,PackageManagement
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.1.1.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script     1.1.0.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Binary     1.0.0.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script     1.1.2.0    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
Script     1.1.0.0    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
> Get-PackageProvider
Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains...
PowerShellGet            1.1.2.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpd...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent
edyoung commented 6 years ago

I believe I've fixed this (in development branch) - issue no longer reproes