Test-ModuleManifest checks if a required module is installed but doesn't check version · Issue #7495 · PowerShell/PowerShell · GitHub
Skip to content

Test-ModuleManifest checks if a required module is installed but doesn't check version #7495

Open

Description

@rjmholt

Test-ModuleManifest will fail if a RequiredModule is not installed on the current machine.

I went and looked at the source out of curiosity, and although we do check, we ignore the other constraints on the module:

It seems like we should:

  1. Commit to doing a full check of the required modules' constraints, since we're already checking they are installed
  2. Give a better error message when a module isn't installed; it currently just says something like:
    Test-ModuleManifest : The specified RequiredModules entry 'banana' in the module manifest '/home/rob/Documents/Dev/sandbox/AModule/AModule.psd1' is invalid. Try again after updating this entry with valid values.       
    At line:1 char:1        
    + Test-ModuleManifest ./AModule.psd1
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (./AModule.psd1:String) [Test-ModuleManifest], DirectoryNotFoundException
    + FullyQualifiedErrorId : Modules_InvalidRequiredModulesinModuleManifest,Microsoft.PowerShell.Commands.TestModuleManifestCommand
    
  3. Provide an option to only check the validity of the manifest itself, and not whether it will work in the current session (this last point I think is part of the need to separate "Module manifests that are not well-formed" from "Module manifests that cannot be loaded in the current session"

Steps to reproduce

> New-ModuleManifest -Path ./AModule.psd1 -RequiredModules @{
ModuleName = 'Microsoft.PowerShell.Utility'
ModuleVersion = '100.0'
}
> Test-ModuleManifest ./AModule.psd1

Expected behavior

<Error message about not having the required version>

Actual behavior


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   0.0.1      AModule                             

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.2
PSEdition                      Core
GitCommitId                    v6.1.0-preview.2
OS                             Linux 4.15.0-30-generic #32-Ubuntu SMP Thu Jul 26 17:42:43 UTC 2018
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. tig commented on Nov 7, 2023

    @tig

    I'd love it if this were fixed.

  2. Ellestad1995 commented on May 6, 2024

    @Ellestad1995

    Don't close, please fix instead 👍

  3. wisemoth commented on Nov 3, 2024

    @wisemoth

    Fix would be great

  4. kilasuit commented on Nov 3, 2024

    @kilasuit
    Collaborator

    I think for this we should keep the "can't be loaded in this session" behaviour but behind a logic change that we invoke via an additional parameter as part of the build and release process you may want to build a module that doesn't require you to have it's dependencies on the build box, but then want them when testing and using the module in realworld use.

    But that is an edge case, that for example you were developing a module using an editior to develop and push off all the build, test and release to other compute resources, where required checks can be done, Example on an iPad, or Phone etc.

  5. added
    Issue-BugIssue has been identified as a bug in the product
    and removed
    Issue-Enhancementthe issue is more of a feature request than a bug
    on Sep 16, 2026
  6. added
    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
    WG-ReviewedA Working Group has reviewed this and made a recommendation
    and removed
    WG-NeedsReviewNeeds a review by the labeled Working Group
    on Sep 16, 2026
  7. SteveL-MSFT commented on Sep 16, 2026

    @SteveL-MSFT
    Member

    The WG discussed this. It is clearly a bug that the requiredModules check happens for the module, but not the version when specified. We also do not want to expand the scope of this issue to cover recursive dependencies nor a switch where Test-ModuleManifest checks the syntax vs whether it's importable which should be a separate issue if needed.

  8. candygoogy commented on Oct 11, 2026

    @candygoogy

    I've been working on this, keeping to the scope above: checking the version of required modules when one is specified, without recursion or a new parameter. I'll open a PR shortly. @PowerShell/powershell could you assign it to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIssue-BugIssue has been identified as a bug in the productUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesWG-ReviewedA Working Group has reviewed this and made a recommendation

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions