fix: resolve Import-Module failure on PowerShell 7.4 (#454)#456
Merged
Conversation
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 <noreply@anthropic.com>
Test Results 3 files 213 suites 25s ⏱️ Results for commit d299406. ♻️ This comment has been updated with latest results. |
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 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Import-Module Plasterfails on PowerShell 7.4 with "The module manifest 'Plaster.psm1' could not be processed because it is not a valid PowerShell module manifest file"Plaster.psm1calledTest-ModuleManifeston its own manifest during initialization, creating a re-entrant validation loop. PS 7.4 added stricter guards that reject this circular pattern; earlier versions were permissive.Test-ModuleManifestwithImport-PowerShellDataFile, which reads the psd1 as a plain hashtable without triggering module validation — no re-entrancy, no circular reference, and works whether the module is loaded via manifest or directly via psm1 path.Fixes #454. Bumps to 2.1.1.
Test plan
Import-Module Plaster -RequiredVersion 2.1.1succeeds on PS 7.4(Get-Module Plaster).Versionreturns2.1.1Plaster v2.1.1 module loaded successfully(not blank)Invoke-psake Test)Generated with Claude Code