PowerShellGetv2 icon indicating copy to clipboard operation
PowerShellGetv2 copied to clipboard

Find-Module -AllowPrerelease Fails

Open awickham10 opened this issue 5 years ago • 5 comments

2.1.4 seems to have broken -AllowPrerelease. I was able to verify it is working in 2.1.3 and only an issue in 2.1.4.

Steps to reproduce

Find-Module PSReadLine -AllowPrerelease

Expected behavior

Return PSReadline modules.

Actual behavior

Find-Package : A parameter cannot be found that matches parameter name 'AllowPrereleaseVersions'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.1.4\PSModule.psm1:8863 char:40
+         PackageManagement\Find-Package @PSBoundParameters | Microsoft ...
+                                        ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Find-Package], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.17134.590
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.590
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.4        PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script     2.1.4      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
> Get-PackageProvider -ListAvailable
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, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet            2.1.4.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Filter, Tag, Includes, DscResource, RoleCapability, Command, AcceptLicense, PublishLocation, Scri...
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, Filter, Tag, Includes, DscResource, RoleCapability, Command, PublishLocation, ScriptSourceLocation, ScriptPublishLocation
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

awickham10 avatar May 22 '19 13:05 awickham10

That's odd. I can't reproduce the problem myself. It might be that you have an old build of packagemanagement or the PowerShellGet packageprovider loaded. Does it still repro if you open a fresh powershell prompt? What do Get-PackageProvider and Get-Module PackageManagement say? (without the ListAvailable)

edyoung avatar May 22 '19 15:05 edyoung

I also wasn't able to repro this

alerickson avatar May 22 '19 18:05 alerickson

I recently ran into this issue. After installing the latest PowershellGet and then closing and restarting my posh console, it was cleared up..

iampeterdaniels avatar Mar 01 '20 15:03 iampeterdaniels

I dont mean to raise the dead here, but thought i had some info that might be helpful:

I installed powershellget 2.2.5 from PSGallery and started having the issue once i started using -SkipAutomaticTags When not using -SkipAutomaticTags, the probelm would go away but i would be stuck publishing modules with the automatically generated tags. This behavior seemed really odd so i started investigating.

I think i found ultimately where this is coming from

the issue is on line 169 in PSModule.psm1:

$script:AllowPrereleaseVersions = "AllowPrereleaseVersions"

on my system, changing it to:

$script:AllowPrereleaseVersions = "AllowPrerelease"

fixed it for me

and after some further digging, I confirmed that in addition to PackageManagment version 1.4.7 i had 1.0.0.1 installed on my system.

After removing PackageManagment module version 1.0.0.1 and reverting the above lines back to original, I am no longer having the problem.

I would still consider this a bug as ideally the module should #require / load /reference the appropriate dependencies minimum versions to prevent dependency mixmatches from presenting to end users. Though I understand if this is more deemed a "user error" issue.

Perhaps a documentation blurb somewhere to let users know to remove the old packagemanagement module from their system if plannng to use this module would be sufficient, forgive me if this already exists and I just didnt find it.

chreestopher avatar Mar 25 '22 16:03 chreestopher

@chreestopher I think I know what the issue was here. If you run Get-Module PowerShellGet, PackageManagement -ListAvailable you get a list of all of the versions that exist on your system. If there's multiple versions installed in different locations then the ordering that is displayed with this output is the ordering PowerShell uses. Meaning, version 1.0.0.1 may have been installed in a location that was a higher priority than 1.4.7.

For example, here PowerShellGet version 2.0.0 would be loaded by default. You would need to explicitly import version 2.2.5 or remove 2.0.0 so that 2.2.5 can be loaded by default. image

We can write a blurb somewhere to make sure this info is a bit more explicitly conveyed 😃

alerickson avatar Mar 28 '22 03:03 alerickson