7.6: startup crash with a multi-path PSModulePath in powershell.config.json (fixed in 7.7 by #26565)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start with the PSModulePath handling in ModuleIntrinsics.cs, in UpdatePath and AddToPath, and the PathContainsSubstring call that returns -1 when the added path holds several entries. Reproduce by setting two paths in powershell.config.json and starting pwsh, which should throw the startIndex error. Done when that case starts cleanly, the order of the paths is kept, and the existing Pester and xUnit module-path tests pass. The maintainers have not yet chosen between backporting #26565 and the smaller fix, so confirm the approach on the issue first.
Written by the indexing model from the issue text.
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)
- Set
PSModulePathinpowershell.config.jsonto two paths, joined with the path separator (;or:). - Start
pwshfrompwsh, or useForEach-Object -Parallel, so$env:PSModulePathis 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
-
Backport #26565, together with the test fixes it needed (#27343, #27344). It is a larger refactor.
-
A smaller fix in
ModuleIntrinsics.cs, which only touches the two places that break:UpdatePath:PathContainsSubstring(path, pathToAdd)returns -1 whenpathToAddholds several paths, sopath.IndexOf(Path.PathSeparator, -1)throws. Look up the last entry ofpathToAddinstead.AddToPath: after inserting an entry, moveinsertPositionpast it, so the paths keep their order, and compare it withresult.Lengthinstead ofbasePath.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.
- Dominant language
- C#
- Stars
- 56.1k
- Forks
- 8.5k
- Avg merge
- 12h 33m
- Merged PRs (30d)
- 73
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PowerShell/PowerShell
-
Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
PowerShell/PowerShell#28432 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Needs-Investigation WG-Engine WG-NeedsReview
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
PowerShell/PowerShell#28283 · 1 comment ·
Maintainers usually reply within 1 day
-
Contributing tab on rendered Readme.md has broken links to two images, under .github/Images, but previews ok in .github/Contributing.mdPossibly taken @Soumilgit claimed this 22 days ago. OpenIssue-Enhancement Needs-Triage
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
PowerShell/PowerShell#28256 · 1 comment ·
Maintainers usually reply within 1 day
-
Issue-Enhancement Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
PowerShell/PowerShell#28138 · 1 reaction ·
Maintainers usually reply within 1 day
-
Add support for WebRequestMethod QUERYPossibly taken @soroshsabz claimed this 52 days ago. OpenIssue-Enhancement Up-for-Grabs WG-Cmdlets WG-Reviewed
Difficulty 1/5 Under an hour Newbie friendliness 86/100
PowerShell/PowerShell#28061 · 4 comments · 3 reactions ·
Maintainers usually reply within 1 day
All issues in PowerShell/PowerShell
Similar issues
-
area-templates triage:bot-seen triage:needs-human
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
microsoft/aspire#22356 · 1 comment ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/aspire.dev#2184 ·
Maintainers usually reply within 2 days
-
area-controls-refreshview platform/ios s/triaged
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
dotnet/maui#40314 · 1 reaction ·
Maintainers usually reply within 1 day
-
Needs: Triage (Functions) v5 v5-preview5
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Azure/azure-functions-core-tools#5918 ·
Maintainers usually reply within 1 day
-
kind:ux needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
elsa-workflows/elsa-foundation#4712 · 1 comment ·
Maintainers usually reply within 1 day