From b85010d152a250ae38a7c84ed4659ad1ad9fbca6 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Mon, 25 May 2026 21:09:28 -0700 Subject: [PATCH 1/2] fix: resolve Import-Module failure on PowerShell 7.4 (#454) Replace re-entrant Test-ModuleManifest call during module init with $MyInvocation.MyCommand.Module.Version. PS 7.4 added stricter guards against circular manifest validation that break the old pattern. Bumps version to 2.1.1. Co-Authored-By: Claude Sonnet 4.6 --- CHANGELOG.md | 11 +++++++++++ Plaster/Plaster.psd1 | 2 +- Plaster/Plaster.psm1 | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f09ac7..9a6b61a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [2.1.1] - 2026-05-25 + +### Fixed + +- `Import-Module Plaster` fails on PowerShell 7.4 with "not a valid + PowerShell module manifest file" error — the module called + `Test-ModuleManifest` on its own manifest during initialization, + causing a re-entrant validation loop that PS 7.4's stricter guards + reject. Replaced with `$MyInvocation.MyCommand.Module.Version` + ([#454](https://github.com/PowerShellOrg/Plaster/issues/454)) + ## [2.1.0] - 2026-05-25 ### Added diff --git a/Plaster/Plaster.psd1 b/Plaster/Plaster.psd1 index 6d99e62..4058217 100644 --- a/Plaster/Plaster.psd1 +++ b/Plaster/Plaster.psd1 @@ -6,7 +6,7 @@ GUID = 'cfce3c5e-402f-412a-a83a-7b7ee9832ff4' # Version number of this module. - ModuleVersion = '2.1.0' + ModuleVersion = '2.1.1' # Supported PSEditions CompatiblePSEditions = @('Desktop', 'Core') diff --git a/Plaster/Plaster.psm1 b/Plaster/Plaster.psm1 index 2dd3e8c..6546452 100644 --- a/Plaster/Plaster.psm1 +++ b/Plaster/Plaster.psm1 @@ -77,7 +77,7 @@ try { # Module variables with proper scoping and type safety [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')] -$PlasterVersion = (Test-ModuleManifest -Path (Join-Path $PSScriptRoot 'Plaster.psd1')).Version +$PlasterVersion = $MyInvocation.MyCommand.Module.Version [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')] $JsonSchemaPath = Join-Path $PSScriptRoot "Schema\plaster-manifest-v2.json" From d299406efc9ffc56d0fe892b19356a7fe89a2945 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Mon, 25 May 2026 21:14:46 -0700 Subject: [PATCH 2/2] fix: use Import-PowerShellDataFile instead of Test-ModuleManifest Import-PowerShellDataFile reads the psd1 as a data hashtable without triggering module validation, so no re-entrancy issue on PS 7.4. Also fixes blank $PlasterVersion when module is loaded directly via psm1 path (as test runners do) rather than via the manifest. Co-Authored-By: Claude Sonnet 4.6 --- Plaster/Plaster.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plaster/Plaster.psm1 b/Plaster/Plaster.psm1 index 6546452..eed1807 100644 --- a/Plaster/Plaster.psm1 +++ b/Plaster/Plaster.psm1 @@ -77,7 +77,7 @@ try { # Module variables with proper scoping and type safety [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')] -$PlasterVersion = $MyInvocation.MyCommand.Module.Version +$PlasterVersion = (Import-PowerShellDataFile -Path (Join-Path $PSScriptRoot 'Plaster.psd1')).ModuleVersion [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')] $JsonSchemaPath = Join-Path $PSScriptRoot "Schema\plaster-manifest-v2.json"