FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

7.6: startup crash with a multi-path PSModulePath in powershell.config.json (fixed in 7.7 by #26565) · Issue #28306 · PowerShell/PowerShell · GitHub

Repository navigation

7.6: startup crash with a multi-path PSModulePath in powershell.config.json (fixed in 7.7 by #26565) #28306

Open

Description

Summary

#20706 is fixed in 7.7 by #26565, but 7.6.x, the current LTS, still crashes. This asks for a fix in 7.6, either by backporting #26565 or with the smaller fix below.

Steps to reproduce (7.6.9)

  1. Set PSModulePath in powershell.config.json to two paths, joined with the path separator (; or :).
  2. Start pwsh from pwsh, or use ForEach-Object -Parallel, so $env:PSModulePath is already set.

Actual behaviour

The shell cannot be started. A failure occurred during initialization:
Index was out of range. Must be non-negative and less than or equal to the size of the collection. (Parameter 'startIndex')

Options

  1. Backport Refactor the module path construction code to make it more robust and easier to maintain #26565, together with the test fixes it needed (ReleaseAutomationTest new failures in 7.7.0-preview.1: module-path / MyDocuments test assumptions (3 distinct cases) #27343, Test failures from module-path refactor PR #26565: tests 103778 / 103842 / 108309 fail on ZIP/TAR/portable distribution lanes #27344). It is a larger refactor.

  2. A smaller fix in ModuleIntrinsics.cs, which only touches the two places that break:

    • UpdatePath: PathContainsSubstring(path, pathToAdd) returns -1 when pathToAdd holds several paths, so path.IndexOf(Path.PathSeparator, -1) throws. Look up the last entry of pathToAdd instead.
    • AddToPath: after inserting an entry, move insertPosition past it, so the paths keep their order, and compare it with result.Length instead of basePath.Length.

    The full Pester and xUnit suites pass on 7.6.9 with it. The diff: https://github.com/ChrisTX/aur-packages/blob/master/powershell/psmodulepath-combined-paths.patch

I can open a PR against the 7.6 release branch for whichever option you prefer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Review - MaintainerThe PR/issue needs a review from the PowerShell repo Maintainers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL