Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Update-ModuleManifest -RequiredModule" complains about invalid manifest #67

Open
5 tasks done
Kuxe opened this issue Feb 21, 2024 · 0 comments
Open
5 tasks done
Labels
bug Something isn't working

Comments

@Kuxe
Copy link

Kuxe commented Feb 21, 2024

Prerequisites

Steps to reproduce

Passing -RequiredModules directly to New-ModuleManifest works:

$ModuleA = New-Object -TypeName Microsoft.PowerShell.Commands.ModuleSpecification @{
	ModuleName = "MyModule"
	RequiredVersion = [semver]"0.1.2"
}

New-ModuleManifest -Path:"$PSScriptRoot/ModuleB.psd1" -RequiredModules:$ModuleA

Passing -RequiredModules to Update-ModuleManifest fails:

$ModuleA = New-Object -TypeName Microsoft.PowerShell.Commands.ModuleSpecification @{
	ModuleName = "MyModule"
	RequiredVersion = [semver]"0.1.2"
}

New-ModuleManifest -Path:"$PSScriptRoot/ModuleB.psd1"
Update-ModuleManifest -Path:"$PSScriptRoot/ModuleB.psd1" -RequiredModules:$ModuleA

A workaround is to ensure that ModuleA is installed, then Update-ModuleManifest won't fail.

Expected behavior

It's possible to set Required Module via Update-ModuleManifest

Actual behavior

It's not possible to set Required Module via Update-ModuleManifest, it errors with

Cannot update the manifest file 'D:\programming\pwsh/ModuleB.psd1' because the manifest is not valid. Verify that the manifest file is valid, and then try again.'The specified RequiredModules entry 'MyModule' in the module
     | manifest 'D:\programming\pwsh\PSGet_ModuleB.psd1' is invalid. Try again after updating this entry with valid values.'

Error details

PS D:\programming\pwsh> Get-Error

Exception             :
    Type       : System.ArgumentException
    Message    : Cannot update the manifest properly. 'The specified RequiredModules entry 'MyModule' in the module manifest 'D:\programming\pwsh\ModuleB.psd1' is invalid. Try again after updating this entry with valid values.'
    TargetSite :
        Name          : ThrowTerminatingError
        DeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.4.1.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Source     : System.Management.Automation
    HResult    : -2147024809
    StackTrace :
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
TargetObject          : D:\programming\pwsh/ModuleB.psd1
CategoryInfo          : InvalidArgument: (D:\programming\pwsh/ModuleB.psd1:String) [Update-ModuleManifest], ArgumentException
FullyQualifiedErrorId : InvalidModuleManifestFile,Update-ModuleManifest
InvocationInfo        :
    MyCommand        : Update-ModuleManifest
    ScriptLineNumber : 7
    OffsetInLine     : 1
    HistoryId        : 21
    ScriptName       : D:\programming\pwsh\Update-ModuleManifest_bug.ps1
    Line             : Update-ModuleManifest -Path:"$PSScriptRoot/ModuleB.psd1" -RequiredModules:$ModuleA
    Statement        : Update-ModuleManifest -Path:"$PSScriptRoot/ModuleB.psd1" -RequiredModules:$ModuleA
    PositionMessage  : At D:\programming\pwsh\Update-ModuleManifest_bug.ps1:7 char:1
                       + Update-ModuleManifest -Path:"$PSScriptRoot/ModuleB.psd1" -RequiredMod …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : D:\programming\pwsh
    PSCommandPath    : D:\programming\pwsh\Update-ModuleManifest_bug.ps1
    InvocationName   : Update-ModuleManifest
    CommandOrigin    : Internal
ScriptStackTrace      : at ThrowError, C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1: line 7115
                        at Update-ModuleManifest, C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1: line 13336
                        at <ScriptBlock>, D:\programming\pwsh\Update-ModuleManifest_bug.ps1: line 7
                        at <ScriptBlock>, <No file>: line 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@SteveL-MSFT SteveL-MSFT transferred this issue from PowerShell/PowerShell Feb 26, 2024
@anamnavi anamnavi added the bug Something isn't working label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants