PowerShell / PowerShellGetv2

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

[BUG] Registering default PSRepostiory fails silently when there's no connection via proxy #612

Open glatzert opened 4 years ago

glatzert commented 4 years ago

Steps to reproduce

Register-PSRepository -Default

Expected behavior

The command has output, which makes it easy to determine, the requested operation failed - possibly with HTTP-failure message.

> Register-PSRepository -Default
--END OF OUTPUT--

> Register-PSRepository -Default -Verbose
VERBOSE: Performing the operation "Register Module Repository." on target "Module Repository 'PSGallery' () in provider 'PowerShellGet'.".
--END OF OUTPUT--

Actual behavior

The command does not return anything indicating an error (not even in Verbose).

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.2
PSEdition                      Core
GitCommitId                    7.0.2
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
> Get-Module -ListAvailable PowerShellGet,PackageManagement

    Directory: C:\program files\powershell\7\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.4.6                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     2.2.4                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     1.0.0.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     1.0.0.1               PowerShellGet                       Desk      {Install-Module, Find-Module, Save-Modu…
> Get-PackageProvider -ListAvailable
Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, …
PowerShellGet            2.2.4.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, In…
PowerShellGet            1.0.0.1
> Get-PSRepository
WARNING: Unable to find module repositories.
glatzert commented 3 years ago

@alerickson today I hit this on a Powershell 7.1 running on windows server core which has outbound connectivity via an http proxy. Register-PSRepository -Default is a noop with no result.

Register-PSRepository -SourceLocation "https://www.powershellgallery.com/api/v2/" -Name "PSGallery" Ends in Register-PSRepository: Use 'Register-PSRepository -Default' to register the PSGallery repository.

This is extremely frustrating.