Powershell: Assertion failure in master: "new Cmdlet added to System.Management.Automation.dll - update InitializeCoreCmdletsAndProviders"

Created on 17 May 2018  路  7Comments  路  Source: PowerShell/PowerShell

Running PowerShell from master on Ubuntu 18.04.

Looks like a new cmdlet has been added to PowerShell and InitializeCoreCmdletsAndProviders has not been updated?

Not sure if this is just me -- may need someone else to reproduce this...

Steps to reproduce

  1. Clone master (commit 4e3db1bb93b17228752de9e3e99f89defbdc01b0) on a supported UNIX-like.
  2. Build in Debug configuration.
  3. Execute the generated PowerShell binary.

Expected behavior

PowerShell starts and presents a prompt.

Actual behavior

PS /home/rob/Documents/Dev/Microsoft/PowerShell> ./src/powershell-unix/bin/Debug/netcoreapp2.1/linux-x64/publish/pwsh                                                                                     
Assertion Failed
new Cmdlet added to System.Management.Automation.dll - update InitializeCoreCmdletsAndProviders

   at System.Management.Automation.Diagnostics.Assert(Boolean condition, String whyThisShouldNeverHappen, String detailMessage) in /home/rob/Documents/Dev/Microsoft/PowerShell/src/System.Management.Automation/utils/assert.cs:line 195
   at System.Management.Automation.Diagnostics.Assert(Boolean condition, String whyThisShouldNeverHappen) in /home/rob/Documents/Dev/Microsoft/PowerShell/src/System.Management.Automation/utils/assert.cs:line 130
   at System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzePSSnapInAssembly(Assembly assembly, String name, PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo, Boolean isModuleLoad, Dictionary`2& cmdlets, Dictionary`2& aliases, Dictionary`2& providers, String& helpFile) in /home/rob/Documents/Dev/Microsoft/PowerShell/src/System.Management.Automation/engine/InitialSessionState.cs:line 5113
   at System.Management.Automation.Runspaces.InitialSessionState.ImportPSSnapIn(PSSnapInInfo psSnapInInfo, PSSnapInException& warning) in /home/rob/Documents/Dev/Microsoft/PowerShell/src/System.Management.Automation/engine/InitialSessionState.cs:line 3766
   at System.Management.Automation.Runspaces.InitialSessionState.ImportCorePSSnapIn() in /home/rob/Documents/Dev/Microsoft/PowerShell/src/System.Management.Automation/engine/InitialSessionState.cs:line 3691
   at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2() in /home/rob/Documents/Dev/Microsoft/PowerShell/src/System.Management.Automation/engine/InitialSessionState.cs:line 1609
   at Microsoft.PowerShell.UnmanagedPSEntry.Start(String consoleFilePath, String[] args, Int32 argc) in /home/rob/Documents/Dev/Microsoft/PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs:line 62
   at Microsoft.PowerShell.ManagedPSEntry.Main(String[] args) in /home/rob/Documents/Dev/Microsoft/PowerShell/src/powershell/Program.cs:line 22

(Failing assertion is here)

Environment data

PS /home/rob/Documents/Dev/Microsoft/PowerShell> uname -a                                            
Linux hyperion 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

PS /home/rob/Documents/Dev/Microsoft/PowerShell> cat /etc/os-release                                 
NAME="Ubuntu"
VERSION="18.04 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
Issue-Bug Resolution-Fixed WG-Engine

All 7 comments

These cmdlets are in cmdletsCheck and not cmdlets where the assertion is failing:

Connect-PSSession
Register-PSSessionConfiguration
Unregister-PSSessionConfiguration
Get-PSSessionConfiguration
Set-PSSessionConfiguration
Enable-PSSessionConfiguration
Disable-PSSessionConfiguration
Enable-PSRemoting
Disable-PSRemoting
Get-PSSessionCapability
Disconnect-PSSession
Enter-PSHostProcess
Exit-PSHostProcess
Get-PSHostProcessInfo
New-PSSessionConfigurationFile
New-PSSessionOption
Receive-PSSession
Test-PSSessionConfigurationFile

Aha! Looks like deleting an #if !UNIX solves this.

I'm assuming the remoting cmdlets were added to UNIX and this was missed (easy to do)...

I'll open a PR.

It seems these cmdlets are not supported on Unix if look our tests.

@PaulHigin, @daxian-dbw, not sure what is going on here. Are the remoting cmdlets enabled on Linux?

Asserting the counts are equal is not very useful here. This should be moved to the end of the loop to get a chance to actually report what cmdlet is missing/extra. Better would be to change the asserts in the loop to error output to ensure all issues are reported before failing.

@dantraMSFT Was thinking similar, we should add that to whatever change fixes this.

I'm still worried that DefaultCommands.Tests.ps1 doesn't catch this.

Was this page helpful?
0 / 5 - 0 ratings