JustinGrote / ModuleFast

A "fast and loose" way to install modules from Powershell Gallery quickly. Meant for CICD, not production
Other
74 stars 5 forks source link

`Install-ModuleFast`: Fails to get plan for Plaster (for latest version 1.1.4) #48

Closed johlju closed 7 months ago

johlju commented 7 months ago
$installModuleFastParameters = @{                             
    Destination          = './output/RequiredModules'
    NoPSModulePathUpdate = $true
    NoProfileUpdate      = $true
    Update               = $true
    Confirm              = $false
}

Install-ModuleFast -Specification 'Plaster' -Plan @installModuleFastParameters -Verbose -Debug

Result:

VERBOSE: Plaster: Evaluating Module Specification                                                                       
DEBUG: Plaster: Skipping PSModulePath /Users/johlju/source/Sampler/output/RequiredModules - Does not have this module.  
DEBUG: Plaster: Skipping 1.1.3 because -Update was specified and the version does not exactly meet the upper bound of the spec or no upper bound was specified at all, meaning there is a possible newer version remotely.
DEBUG: Plaster: New Best Candidate Version 1.1.3                                                                        
DEBUG: Plaster: Skipping 1.1.4 because -Update was specified and the version does not exactly meet the upper bound of the spec or no upper bound was specified at all, meaning there is a possible newer version remotely.
Install-ModuleFast: Could not compare "1.1.4" to "Plaster(1.1.3)". Error: "Cannot convert the "Plaster(1.1.3)" value of type "ModuleFastInfo" to type "NuGet.Versioning.NuGetVersion"."

[!NOTE] Using v0.1.0-rc1

johlju commented 7 months ago

This happened when v1.1.3 and v1.1.4 was installed in a PSModulePath.

PS> get-module plaster -ListAvailable                 

    Directory: /Users/johlju/.local/share/powershell/Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.1.4                 Plaster                             Desk      {Invoke-Plaster, New-PlasterManifest, Get-PlasterTemplate, Test-PlasterManifest}
Script     1.1.3                 Plaster                             Desk      {Invoke-Plaster, New-PlasterManifest, Get-PlasterTemplate, Test-PlasterManifest}

    Directory: /Users/johlju/.vscode/extensions/ms-vscode.powershell-2023.8.0/modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.1.3                 Plaster                             Desk      {Invoke-Plaster, New-PlasterManifest, Get-PlasterTemplate, Test-PlasterManifest}

When I removed the versions already installed in /Users/johlju/.local/share/powershell/Modules it correctly resolved:

 VERBOSE: Plaster: Evaluating Module Specification                                                                       
DEBUG: Plaster: Skipping PSModulePath /Users/johlju/source/Sampler/output/RequiredModules - Does not have this module.  
DEBUG: Plaster: Skipping PSModulePath /Users/johlju/.local/share/powershell/Modules - Does not have this module.        
DEBUG: Plaster: Skipping PSModulePath /usr/local/share/powershell/Modules - Does not have this module.                  
DEBUG: Plaster: Skipping PSModulePath /usr/local/microsoft/powershell/7/Modules - Does not have this module.            
DEBUG: Plaster: Skipping 1.1.3 because -Update was specified and the version does not exactly meet the upper bound of the spec or no upper bound was specified at all, meaning there is a possible newer version remotely.
DEBUG: Plaster: New Best Candidate Version 1.1.3                                                                        
DEBUG: Plaster: 🔍 No installed versions matched the spec. Will check remotely.                                         
DEBUG: REQUEST CACHE HIT for Registration Index https://pwsh.gallery/index.json                                         
DEBUG: REQUEST CACHE HIT for https://pwsh.gallery/plaster/index.json                                                    
DEBUG: Plaster: Processing Response                                                                                     
DEBUG: Plaster: Received Response with 2 pages                                                                          
DEBUG: Plaster: Found satisfying version 1.1.4 in the inlined index.                                                    
VERBOSE: Plaster(1.1.4): Added to install plan                                                                          
VERBOSE: 📑 -Plan was specified. Returning a plan including 1 Module Specifications                                     

Name    ModuleVersion Location                                                                                          
----    ------------- --------                                                                                          
Plaster 1.1.4         https://www.powershellgallery.com/api/v2/package/Plaster/1.1.4 
johlju commented 7 months ago

The same issue with PSScriptAnalyzer:

PS> get-module PSScriptAnalyzer -ListAvailable        

    Directory: /Users/johlju/.local/share/powershell/Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.19.1                PSScriptAnalyzer                    Desk      {Get-ScriptAnalyzerRule, Invoke-ScriptAnalyzer, Invoke-Formatter}
Script     1.18.3                PSScriptAnalyzer                    Desk      {Get-ScriptAnalyzerRule, Invoke-ScriptAnalyzer, Invoke-Formatter}

    Directory: /Users/johlju/.vscode/extensions/ms-vscode.powershell-2023.8.0/modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.21.0                PSScriptAnalyzer                    Desk      {Get-ScriptAnalyzerRule, Invoke-ScriptAnalyzer, Invoke-Formatter}

PS>                 $installModuleFastParameters = @{                                                 
>>                     Destination          = './output/RequiredModules'
>>                     NoPSModulePathUpdate = $true
>>                     NoProfileUpdate      = $true
>>                     Update               = $true
>>                     Confirm              = $false
>>                 }
PS> Install-ModuleFast -Specification 'PSScriptAnalyzer' -Plan @installModuleFastParameters -Verbose -Debug
VERBOSE: PSScriptAnalyzer: Evaluating Module Specification                                                              
DEBUG: PSScriptAnalyzer: Skipping PSModulePath /Users/johlju/source/Sampler/output/RequiredModules - Does not have this module.
DEBUG: PSScriptAnalyzer: Skipping 1.19.1 because -Update was specified and the version does not exactly meet the upper bound of the spec or no upper bound was specified at all, meaning there is a possible newer version remotely.
DEBUG: PSScriptAnalyzer: New Best Candidate Version 1.19.1                                                              
DEBUG: PSScriptAnalyzer: Skipping 1.18.3 because -Update was specified and the version does not exactly meet the upper bound of the spec or no upper bound was specified at all, meaning there is a possible newer version remotely.
Install-ModuleFast: Could not compare "1.18.3" to "PSScriptAnalyzer(1.19.1)". Error: "Cannot convert the "PSScriptAnalyzer(1.19.1)" value of type "ModuleFastInfo" to type "NuGet.Versioning.NuGetVersion"."
JustinGrote commented 7 months ago

Good catch! I'll take a look.