Repository navigation
Test-ModuleManifest working sporadically on v6.1.0-preview.2 #6818
Copy link
Copy link
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Description
If it is a bug report:
- make sure you are able to repro it on the latest released version. I'm able to reproduce it in the latest version.
You can install the latest version from https://github.com/PowerShell/PowerShell/releases - Search the existing issues. Tried that. No open issues matched. Allthough this closed one is quite similar Test-ModuleManifest fails on manifest from New-ModuleManifest #6676
- Refer to the FAQ. not related to this issue
- Refer to the known issues. no known issues matches this one
- Fill out the following repro template:
Steps to reproduce
PS > pwsh
PS > Test-ModuleManifest -Path /reposDir/MyModule/Builds/BuildOutput/Mymodule/MyModule.psd1 -Verbose
N.B. This is a sporadic issue.
- As I have been troubleshooting this I worked on it in the morning. Then when I come home, my laptop hibernating, the exact same command might work again.
- In VS Code I have setup a build task which basically copies the necessary module files, leaving .gitignore, logs and other files I don't want included when publishing the module. If I run the
Test-ModuleManifestcmdlet against the files that was written via the "build" task. It might fail. However, if I runTest-ModuleManifestagainst the .psd1 file in the root of the repo it might work. And vice versa. - I have read > https://msdn.microsoft.com/en-us/library/dd878337(v=vs.85).aspx ...
- I compared my manifest against the manifest of public and solid modules such as Pester and Plaster. I cannot see any issues with my manifest. And! As I've stated, sometimes
Test-ModuleManifestworks on the MyModule.psd1 manifest. Without me chaning anything in the MyModule.psd1 file. - I've tried to execute
Import-Moduleon both the MyModule.psm1 and the MyModule.psd1 files and they successfully import. - For good meassure here is the manifest of my module. Which
Test-ModuleManifestsometimes an test successfully and sometimes not.
@{
# Script module or binary module file associated with this manifest.
RootModule = 'MyModule.psm1'
# ID used to uniquely identify this module
GUID = 'c1e187cd-222f-4df6-8238-88f90f0284ff'
# Version number of this module.
ModuleVersion = '0.0.12'
# Author of this module
Author = 'https://github.com/larssb | https://bengtssondd.it'
# Company or vendor of this module
CompanyName = 'Bengtsson Driven Development'
# Copyright statement for this module
Copyright = '(C) https://github.com/larssb | https://bengtssondd.it. All rights reserved.'
# Description of the functionality provided by this module
Description = 'A project containing helper functions and other utilities to make your life programming PowerShell easier.'
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
'Add-ScheduledTask'
'get-environmentOS'
'get-hostname'
'Get-PSProgramFilesModulesPath'
'Get-PublicFunctions'
'Get-xScheduledTask'
'initialize-log4net'
'New-ScheduledJob'
'out-functionHierarchy'
'Set-xScheduledTask'
'start-externalSoftware'
'test-powershellRunMode'
'import-jsonFile'
)
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
#VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = False
# External dependent modules of this module
# ExternalModuleDependencies = ''
}
}
}
Expected behavior
That Test-ModuleManifest does not throw (as long as you really have a valid manifest file)
Actual behavior
Throws: Test-ModuleManifest : The module manifest 'MyModule' could not be processed because it is not a valid PowerShell module manifest file. Remove the elements that are not permitted: /reposDir/MyModule/Builds/BuildOutput/Mymodule/MyModule.psd1
At line:1 char:1
+ Test-ModuleManifest -Path /MyModule/Builds/BuildOutput/Mymod ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (/MyModule/MyM...d.psd1:String) [Test-ModuleManifest], ArgumentException
+ FullyQualifiedErrorId : Modules_InvalidRootModuleInModuleManifest,Microsoft.PowerShell.Commands.TestModuleManifestCommand
Environment data
OS: MacOS
OS v.: 10.13.5 Beta
PS > pwsh
PS > $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-preview.2
PSEdition Core
GitCommitId v6.1.0-preview.2
OS Darwin 17.6.0 Darwin Kernel Version 17.6.0: Fri Apr 13 19:57:44 PDT 2018; root:xnu-4570.60.17.0.1~3/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Any help is appreciated. Thank you very much.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Activity
iSazonov commentedon May 4, 2018
/cc Dongbo Wang (@daxian-dbw)
daxian-dbw commentedon May 8, 2018
This is not a recent regression. It repros in PS Core 6.0.1.
daxian-dbw commentedon May 11, 2018
Lars Bing Bong. (@larssb) I tried your
.psd1on my machine, and it failed because itTest-ModuleManifestcannot find the root module fileMyModule.psm1. The fact that you observe this failure inconsistently might suggest that theMyModule.psm1file is not deployed by the "build" task whenTest-ModuleManifestruns.But I do think the behavior of
Test-ModuleManifestis not right in this case, see it's result:The error message should be improved to mention it could be the file is not found. And, should that be an terminating error? The returned result incorectly indicates the module is a binary module ...
larssb commentedon May 17, 2018
Hi Dongbo Wang (@daxian-dbw),
Thank you for troubleshooting and sorry for the late reply.
Hmm...:
In order to correctly test it don't you have to:
And agree any error message improvements, and those can be had, would be great.
Thank you.
larssb commentedon Jun 13, 2018
Any news on this?
marckassay commentedon Jul 11, 2018
Dongbo Wang (@daxian-dbw), I'm experiencing similar behavior, if not the same as Lars Bing Bong. (@larssb) has mentioned. Currently I'm working on PowerShellGet #294 issue for Update-ModuleManifest which uses Test-ModuleManifest internally.
When I'm stepping thru Update-ModuleManifest, I'll introspect the data going into Test-ModuleManifest and it looks good. But the data that it returns is missing or strangely in some cases, reverted to previous values.
After glancing into Test-ModuleManifest source code several times I have a couple of questions.
Hopefully that is explained clearly, if not please let me know.
jzabroski commentedon Sep 9, 2018
I believe I have run into this issue on PowerShell v5 and I don't think it's a recent regression. I think it's been buggy since PowerShell v2.
The crux of the problem is the C# code inherits from ModuleCmdletsBase class, which is apparently stateful.
See my bug report in Powershellget here https://github.com/PowerShell/PowerShellGet/issues/321#issuecomment-419614919
Suffice to say, this could be a major security vulnerability.
jzabroski commentedon Sep 12, 2018
How do I test against older versions of PowerShell? I believe I can 100% reproduce this issue, and that it is not at all "sporadic" in nature. The issue is that ModuleCmdletBase caches stuff stupidly, and is poorly written and/or doesn't make sense when you're doing local development on a new module.
iSazonov commentedon Sep 13, 2018
John Zabroski (@jzabroski) Could you please add simple repo steps?
mklement0 commentedon Dec 3, 2018
Dongbo Wang (@daxian-dbw), Lars Bing Bong. (@larssb): Re improving the error message: please see #6683
mklement0 commentedon Dec 3, 2018
In addition to the debatable behavior mentioned by Dongbo Wang (@daxian-dbw) - that a module-info object is still output even if the specified manifest is invalid - here's a simple reproduction that shows the unexpected statefulness of
Test-ModuleManifestmentioned by John Zabroski (@jzabroski):Setup:
At this point,
Test-ModuleManifestsucceeds.Now, make the
RootModuleentry invalid and change the version number, and then runTest-ModuleManifestagain:Now run
Test-ModuleManifestagain, which should now fail:While the output reflects the changed version number, the fact that the
RootModuleentry is now "invalid" was missed - see #8388To verify that the manifest is now indeed invalid, open a new PowerShell session and run the last command again.
jzabroski commentedon Dec 3, 2018
Ilya (@iSazonov) I don't need to outline repro steps. Just look at how BAD this code is:
PowerShell/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs
Lines 345 to 352 in 79f21b4
The ONLY way to clear your AnalysisCache is to restart PowerShell.exe - good luck getting rid of bug reports that PowerShell sucks if people cannot reliably build modules in it. I realize this was done to speed up powershell, but I keep pointing out to Microsoft engineers they are going about improving performance the wrong way.
jzabroski commentedon Dec 3, 2018
Michael Klement (@mklement0) Thank you. I humbly suggest I owe you a beer, for simply doing your job correctly.
12 remaining items
jzabroski commentedon Apr 2, 2019
@TheIncorrigible1 DId you read me notes on this issue?
Basically, the issue is that the Module Analysis cache cannot be fully disabled. The only solution is to continuously close and re-open your terminal by creating new sessions / runspaces.
morsley commentedon Apr 2, 2019
Yes, I read your responses, but the only thing that worked for me was using
Get-Module -Refresh.jzabroski commentedon Apr 2, 2019
The only way to clear your module analysis cache is to close your pwsh.exe process. This will terminate the cache, since the cache is in-process and not global to the OS. I'm not sure why
Get-Module -Refreshworked for you - are you able to consistently reproduce that behavior?morsley commentedon Apr 3, 2019
John Zabroski (@jzabroski) Again, didn't work. None of the remediation worked except what I noted. It wasn't consistent that it resolved the issue; I ended up manually changing the call to the cmdlet to use
Import-PowerShellDataFileinstead.jzabroski commentedon Apr 3, 2019
@TheIncorrigible1 I think I see the nuance - in your case, you've installed a module locally, and you are using
Import-Module YourModule -Forceto clear the old module from the local disk cache (as opposed to memory cache)? Do I have it right? I think the painful part for me is that -Verbose on these commands is not helpfuliSazonov commentedon Apr 4, 2019
John Zabroski (@jzabroski) Please follow Code of Conduct Be respectful.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.