blish-hud / bhud-pkgs

The Blish HUD module manifest repository
7 stars 17 forks source link

Powershell version hell #15

Open OpNop opened 3 years ago

OpNop commented 3 years ago

Just ran into this when running the automated script

Started running it in normal PowerShell that comes with windows (5.1.19041.610) as of windows 10 20H2 ran Import-Module BhudLib and got the errors saying it needed PS version 6.0 or higher

Import-Module : The version of Windows PowerShell on this computer is '5.1.19041.610'. The module 'C:\Program
Files\WindowsPowerShell\Modules\BhudLib\1.0.0\BhudLib.psd1' requires a minimum Windows PowerShell version of '6.0' to
run. Verify that you have the minimum required version of Windows PowerShell installed, and then try again.
At line:1 char:1
+ Import-Module BhudLib
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (C:\Program File....0\BhudLib.psd1:String) [Import-Module], Invalid
   OperationException
    + FullyQualifiedErrorId : Modules_InsufficientPowerShellVersion,Microsoft.PowerShell.Commands.ImportModuleCommand

Had PS6 installed so moved over to it, and try and run Import-Module BhudLib and get error saying I need PS7 now

. : The script 'BhudModuleLib.ps1' cannot be run because it contained a "#requires" statement for PowerShell 7.0. The version of PowerShell that is required by the script does not match the currently running version of PowerShell 6.1.3.
At C:\Program Files\PowerShell\Modules\BhudLib\1.0.0\BhudLib.psm1:3 char:3
+ . "$PSScriptRoot\BhudModuleLib.ps1"
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (BhudModuleLib.ps1:String) [], ScriptRequiresException
+ FullyQualifiedErrorId : ScriptRequiresUnmatchedPSVersion

At C:\Program Files\PowerShell\Modules\BhudLib\1.0.0\BhudPkgLib.ps1:18 char:22
+     BhudPkgManifest([BhudModule] $module, [String] $downloadUrl) {
+                      ~~~~~~~~~~
Unable to find type [BhudModule].
At C:\Program Files\PowerShell\Modules\BhudLib\1.0.0\BhudPkgLib.ps1:29 char:32
+     [Void] PopulateFromModule([BhudModule] $module) {
+                                ~~~~~~~~~~
Unable to find type [BhudModule].
+ CategoryInfo          : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : TypeNotFound

I recommend putting a note in readme that says to just use PS7

dlamkins commented 3 years ago

Good idea. Looks like I also have a mismatch of the requirement statements compared to the psm1 files.

https://github.com/blish-hud/bhud-pkgs/blob/2d69d4ea062437861d461a8915bfcc51195aaf15/tools/BhudLib/BhudLib.psd1#L9 https://github.com/blish-hud/bhud-pkgs/blob/2d69d4ea062437861d461a8915bfcc51195aaf15/tools/BhudLib/BhudLib.psm1#L1 https://github.com/blish-hud/bhud-pkgs/blob/2d69d4ea062437861d461a8915bfcc51195aaf15/tools/BhudLib/BhudModuleLib.ps1#L1 https://github.com/blish-hud/bhud-pkgs/blob/2d69d4ea062437861d461a8915bfcc51195aaf15/tools/BhudLib/BhudPkgLib.ps1#L1