Skip to content

System.IO.DirectoryNotFoundException using -Parallel feature and Microsoft.PowerShell.SDK #13189

@normj

Description

@normj

This is a part 2 of #13132. I'm running PowerShell scripts using executed from a .NET program using Microsoft.PowerShell.SDK. The package bundle is created using --runtime linux-x64 switch with dotnet publish.

Initially I it was always failing and with the previous issue it was discovered I need to move the Modules folder in the runtimes folder up to the root of the publish folder.

Now that I have implemented that workaround of moving the Module folder to the root of the publish folder I'm getting the following error about 10% of the time.

The repo is the same as is explained in the #13132 except before executing the runtimes/win/lib/netcoreapp3.1/Modules folder is copied up to root of the publish folder.

@daxian-dbw

2020-07-15 23:21:04: [Error] - An unexpected error has occurred while processing ForEach-Object -Parallel input. This may mean that some of the piped input did not get processed. Error: System.IO.DirectoryNotFoundException: Could not find a part of the path '/tmp/32029fe7-1d55-4203-bdb1-898dfea7c7d0/.local/share/powershell/Modules'.
   at System.IO.FileSystem.CreateDirectory(String fullPath)
   at System.IO.Directory.CreateDirectory(String path)
   at System.Management.Automation.Platform.SelectProductNameForDirectory(XDG_Type dirpath)
   at System.Management.Automation.ModuleIntrinsics.GetPersonalModulePath()
   at System.Management.Automation.ModuleIntrinsics.GetModulePath(String currentProcessModulePath, String hklmMachineModulePath, String hkcuUserModulePath)
   at System.Management.Automation.ModuleIntrinsics.SetModulePath()
   at System.Management.Automation.ModuleIntrinsics..ctor(ExecutionContext context)
   at System.Management.Automation.ExecutionContext.InitializeCommon(AutomationEngine engine, PSHost hostInterface)
   at System.Management.Automation.ExecutionContext..ctor(AutomationEngine engine, PSHost hostInterface, InitialSessionState initialSessionState)
   at System.Management.Automation.AutomationEngine..ctor(PSHost hostInterface, InitialSessionState iss)
   at System.Management.Automation.Runspaces.LocalRunspace.DoOpenHelper()
   at System.Management.Automation.Runspaces.LocalRunspace.OpenHelper(Boolean syncCall)
   at System.Management.Automation.Runspaces.RunspaceBase.CoreOpen(Boolean syncCall)
   at System.Management.Automation.Runspaces.RunspaceBase.Open()
   at System.Management.Automation.PSTasks.PSTaskBase.Start()
   at System.Management.Automation.PSTasks.PSTaskPool.Add(PSTaskBase task)
   at Microsoft.PowerShell.Commands.ForEachObjectCommand.<InitParallelParameterSet>b__63_2(Object _).

Environment data

{
  "SerializationVersion": {
    "Major": 1,
    "Minor": 1,
    "Build": 0,
    "Revision": 1,
    "MajorRevision": 0,
    "MinorRevision": 1
  },
  "WSManStackVersion": {
    "Major": 3,
    "Minor": 0,
    "Build": -1,
    "Revision": -1,
    "MajorRevision": -1,
    "MinorRevision": -1
  },
  "PSCompatibleVersions": [
    {
      "Major": 1,
      "Minor": 0,
      "Build": -1,
      "Revision": -1,
      "MajorRevision": -1,
      "MinorRevision": -1
    },
    {
      "Major": 2,
      "Minor": 0,
      "Build": -1,
      "Revision": -1,
      "MajorRevision": -1,
      "MinorRevision": -1
    },
    {
      "Major": 3,
      "Minor": 0,
      "Build": -1,
      "Revision": -1,
      "MajorRevision": -1,
      "MinorRevision": -1
    },
    {
      "Major": 4,
      "Minor": 0,
      "Build": -1,
      "Revision": -1,
      "MajorRevision": -1,
      "MinorRevision": -1
    },
    {
      "Major": 5,
      "Minor": 0,
      "Build": -1,
      "Revision": -1,
      "MajorRevision": -1,
      "MinorRevision": -1
    },
    {
      "Major": 5,
      "Minor": 1,
      "Build": 10032,
      "Revision": 0,
      "MajorRevision": 0,
      "MinorRevision": 0
    },
    {
      "Major": 6,
      "Minor": 0,
      "Build": 0,
      "Revision": -1,
      "MajorRevision": -1,
      "MinorRevision": -1
    },
    {
      "Major": 6,
      "Minor": 1,
      "Build": 0,
      "Revision": -1,
      "MajorRevision": -1,
      "MinorRevision": -1
    },
    {
      "Major": 6,
      "Minor": 2,
      "Build": 0,
      "Revision": -1,
      "MajorRevision": -1,
      "MinorRevision": -1
    },
    {
      "Major": 7,
      "Minor": 0,
      "Build": 2,
      "Revision": -1,
      "MajorRevision": -1,
      "MinorRevision": -1
    }
  ],
  "Platform": "Unix",
  "GitCommitId": "7.0.2",
  "PSRemotingProtocolVersion": {
    "Major": 2,
    "Minor": 3,
    "Build": -1,
    "Revision": -1,
    "MajorRevision": -1,
    "MinorRevision": -1
  },
  "PSVersion": {
    "Major": 7,
    "Minor": 0,
    "Patch": 2,
    "PreReleaseLabel": null,
    "BuildLabel": null
  },
  "PSEdition": "Core",
  "OS": "Linux 4.14.165-102.205.amzn2.x86_64 #1 SMP Fri Feb 14 22:46:57 UTC 2020"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions