JustinGrote / ModuleFast

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

`Get-ModuleFastPlan`: Fails to find/return latest Pester version when v3.4.0 is available #20

Closed johlju closed 8 months ago

johlju commented 8 months ago

Calling

@('Pester') | Get-ModuleFastPlan

returns nothing for me which is strange. I only have Pester v3.4.0 installed so expected that to return latest version of Pester.

If I remove the path entry in $env:PSModulePath that points to Pester v.3.4.0 it finds the latest Pester version.

PS> @('Pester!') | Get-ModuleFastPlan

Name   ModuleVersion
----   -------------
Pester 5.5.0

PS> @('Pester') | Get-ModuleFastPlan

Name   ModuleVersion
----   -------------
Pester 5.5.0

PS> @('Pester@4.10.1') | Get-ModuleFastPlan
Get-ModuleFastPlan: Exception calling "GetResult" with "0" argument(s): "Response status code does not indicate success: 501 (Not Implemented)."

[!NOTE] Using the code in main branch.

johlju commented 8 months ago

This does not seem to be an issue for Install-ModuleFast. It installed Pester v5.5.0 even when v3.4.0 exist. So it is just Get-ModuleFastPlan that has this problem.

JustinGrote commented 8 months ago

Note that install-modulefast -whatif will be replacing get-modulefastplan unless I can find a good way to keep the parameter logic all up to date between them, but get-modulefastplan will be preserved with a warning.

I'll investigate this as install-modulefast just turns around to call get-modulefastplan so most things should be fine if you are specifying legacy formats.

johlju commented 8 months ago

Note that install-modulefast -whatif will be replacing get-modulefastplan

I am using Get-ModuleFastPlan to get a result to programmatically see what is needed to be updated. WhatIf wouldn't help with that, so sorry to see it go. I rather see it still being a supported public command. Open issue https://github.com/JustinGrote/ModuleFast/issues/27 for discussion.

johlju commented 8 months ago

I'll investigate this as install-modulefast just turns around to call get-modulefastplan

See below that it does not try to compare latest version - at least no output says so:

PS> $PSDefaultParameterValues

Name                           Value
----                           -----
*-ModuleFast:Source            https://preview.pwsh.gallery/index.json

PS> @('Pester') | Get-ModuleFastPlan
PS> @('Pester') | Get-ModuleFastPlan -Debug -Verbose
VERBOSE: Pester (, ): Evaluating Module Specification
DEBUG: Pester: PSModulePath C:\source\SqlServerDsc\output\builtModule does not have this module. Skipping...
DEBUG: Pester: PSModulePath C:\source\SqlServerDsc\output\RequiredModules does not have this module. Skipping...
DEBUG: Pester: PSModulePath C:\Users\johlju\OneDrive - XXXX\Documents\PowerShell\Modules does not have this module. Skipping...
DEBUG: Pester: PSModulePath C:\Program Files\PowerShell\Modules does not have this module. Skipping...
DEBUG: Pester: PSModulePath c:\program files\powershell\7\Modules does not have this module. Skipping...
DEBUG: Pester (, ): module folder exists at C:\Program Files\WindowsPowerShell\Modules\Pester but no modules found that match the version spec.
DEBUG: Pester: PSModulePath C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules does not have this module. Skipping...
DEBUG: FOUND local module Pester 3.4.0 at file:///C:/Program Files/WindowsPowerShell/Modules/Pester/3.4.0/Pester.psd1 that satisfies Pester (, ). Skipping...
johlju commented 8 months ago

Okay so I see what is going on. I'm not using parameter Update. I do that for the Install-ModuleFast command in my code, but not for Get-ModuleFastPlan. If I run Install-ModuleFast without Update I get the same result.

PS> Install-ModuleFast 'Pester' -Debug -Verbose -Destination .\output\RequiredModules\ -NoPSModulePathUpdate -NoProfileUpdate
VERBOSE: Pester (, ): Evaluating Module Specification
DEBUG: Pester: PSModulePath C:\source\SqlServerDsc\output\builtModule does not have this module. Skipping...
DEBUG: Pester: PSModulePath C:\source\SqlServerDsc\output\RequiredModules does not have this module. Skipping...
DEBUG: Pester: PSModulePath C:\Users\johlju\OneDrive - XXXX\Documents\PowerShell\Modules does not have this module. Skipping...
DEBUG: Pester: PSModulePath C:\Program Files\PowerShell\Modules does not have this module. Skipping...
DEBUG: Pester: PSModulePath c:\program files\powershell\7\Modules does not have this module. Skipping...
DEBUG: Pester (, ): module folder exists at C:\Program Files\WindowsPowerShell\Modules\Pester but no modules found that match the version spec.
DEBUG: Pester: PSModulePath C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules does not have this module. Skipping...
DEBUG: FOUND local module Pester 3.4.0 at file:///C:/Program Files/WindowsPowerShell/Modules/Pester/3.4.0/Pester.psd1 that satisfies Pester (, ). Skipping...
VERBOSE: ✅ 1 Module Specifications have all been satisfied by installed modules. If you would like to check for newer versions remotely, specify -Update
johlju commented 8 months ago

So I guess my thought that just calling 'pester' | Get-ModuleFastPlan or Install-ModuleFast 'Pester' would get me the latest Pester version was not correct. This is by design.

Using -Update gives me the expected behavior.

PS> @('Pester') | Get-ModuleFastPlan -Update

Name   ModuleVersion
----   -------------
Pester 5.5.0
JustinGrote commented 8 months ago

So I guess my thought that just calling 'pester' | Get-ModuleFastPlan or Install-ModuleFast 'Pester' would get me the latest Pester version was not correct. This is by design.

Using -Update gives me the expected behavior.

PS> @('Pester') | Get-ModuleFastPlan -Update

Name   ModuleVersion
----   -------------
Pester 5.5.0

Correct, there will be more detail in the help but modulefast is designed to satisfy your stated module requirements as fast as possible. You can see this in the debug output, if you had specified 'pester>5.4.0' for instance, and 5.5 wasn't already installed, it would plan for it if you only had 3.4 installed