Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository 'PSGallery' is not a known repository type that is supported error when finding packages #1748

Open
3 tasks done
variableresistor opened this issue Nov 8, 2024 · 4 comments

Comments

@variableresistor
Copy link

variableresistor commented Nov 8, 2024

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

# Install the Secrets Management module
"Microsoft.PowerShell.SecretManagement","Microsoft.PowerShell.SecretStore" | Where-Object { -not (Get-Module $_ -ListAvailable)} | ForEach-Object -Process { Install-PSResource -Name $_ -Verbose }
$Cred = Get-Credential
Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault -PassThru -Verbose
Set-SecretStorePassword -NewPassword $Cred.Password -Password $Cred.Password
$CredInfo = [Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo]::new("SecretStore","shared-powershell-hosted-dev")
Register-PSResourceRepository -Name shared-powershell-hosted-dev -Uri https://nexus.mycompany.com/repository/shared-powershell-hosted-dev/ -Trusted -CredentialInfo $CredInfo

Get-PSResourceRepository -Name shared-powershell-hosted-dev | Select *
Find-PSResource -Name PSScriptAnalyzer
Name           : shared-powershell-hosted-dev
Uri            : https://nexus.cityntl.com/repository/shared-powershell-hosted-dev/
Trusted        : True
Priority       : 50
CredentialInfo : Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo
ApiVersion     : unknown

Expected behavior

Should list the available modules in the PSGallery, just like Find-Module does with the below results:
Version              Name                                Repository           Description
-------              ----                                ----------           -----------
1.23.0               PSScriptAnalyzer                    PSGallery            PSScriptAnalyzer provides

Actual behavior

Find-PSResource: Repository 'shared-powershell-hosted-dev' is not a known repository type that is supported. Please file an issue for support at https://github.com/PowerShell/PSResourceGet/issues

Error details

Exception             :
    Type    : Microsoft.PowerShell.PSResourceGet.UtilClasses.ResourceNotFoundException
    Message : Package 'PSScriptAnalyzer' could not be found in any registered repositories.
    HResult : -2146233088
TargetObject          : Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper
CategoryInfo          : ObjectNotFound: (Microsoft.PowerShel….Cmdlets.FindHelper:FindHelper) [Find-PSResource],
ResourceNotFoundException
FullyQualifiedErrorId : PackageNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource
InvocationInfo        :
    MyCommand        : Find-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 1
    Line             : Find-PSResource -Name PSScriptAnalyzer
    Statement        : Find-PSResource -Name PSScriptAnalyzer
    PositionMessage  : At line:1 char:1
                       + Find-PSResource -Name PSScriptAnalyzer
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Find-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
      0
      1

Environment data

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     1.0.6                 Microsoft.PowerShell.PSResourceGet  {Find-PSResource, Get-InstalledPSResource, Get-PSResourceRepository, Get-PSSc…

Key   : PSVersion
Value : 7.4.6
Name  : PSVersion


Key   : PSEdition
Value : Core
Name  : PSEdition


Key   : GitCommitId
Value : 7.4.6
Name  : GitCommitId


Key   : OS
Value : Microsoft Windows 10.0.22631
Name  : OS


Key   : Platform
Value : Win32NT
Name  : Platform


Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0…}
Name  : PSCompatibleVersions


Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion


Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion


Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion

Visuals

No response

@alerickson
Copy link
Member

alerickson commented Nov 8, 2024

Hi @variableresistor, please run Set-PSResourceRepository PSGallery -ApiVersion V2. I'm not sure how the ApiVersion got set to unknown but it should be v2 to interact with the PowerShell Gallery.

@variableresistor
Copy link
Author

Yeah, totally surprised me too. And I work with NuGet repos all day. I wonder if it's some sort of default setting when installing PowerShell. I'll run that at the office tomorrow and will try it out on some other fresh Windows 11 machines.

@variableresistor
Copy link
Author

That worked. Will reopen if it surfaces again on a fresh install.

@variableresistor
Copy link
Author

Updated reproduction steps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants