You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
7.6: startup crash with a multi-path PSModulePath in powershell.config.json (fixed in 7.7 by #26565) #28306
#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 PSModulePath in powershell.config.json to two paths, joined with the path separator (; or :).
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')
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.
Activity
powershell: link the 7.6 request for the PSModulePath fix
powershell-lts: link the 7.6 request for the PSModulePath fix
powershell-lts: link the 7.6 request for the PSModulePath fix
powershell: link the 7.6 request for the PSModulePath fix