Skip to content

On launch, insert PSHOME\Modules into PSModulePath before the Windows PowerShell module path - #7727

Merged
Travis Plunk (TravisEz13) merged 2 commits into
PowerShell:masterfrom
dantraMSFT:dantra/issue7679
Sep 10, 2018
Merged

Travis Plunk (TravisEz13) merged 2 commits into
PowerShell:masterfrom
dantraMSFT:dantra/issue7679

Conversation

@dantraMSFT

Copy link
Copy Markdown
Contributor

Fix #7679

PR Summary

This change updates ModuleIntrinsics.GetModulePath to handle the case where the Windows PowerShell module path is already in the environment's PSModulePath or when launched from a different version of PowerShell.

Previously, GetModulePath would append $PSHOME\Modules to the PSModulePath after removing the path for the launching version without considering the Windows PowerShell module path. The result, was the Windows PowerShell modules were found first and loaded incompatible modules; such as the built-in modules.

The change detects the Windows PowerShell module path and inserts $PSHOME\Modules path before it. The new test simulates launching from a different version of pwsh that has already added the Windows PowerShell module path.

PR Checklist

@rjmholt Rob Holt (rjmholt) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TravisEz13
Travis Plunk (TravisEz13) merged commit 4683934 into PowerShell:master Sep 10, 2018
@dantraMSFT
Dan Travison (dantraMSFT) deleted the dantra/issue7679 branch September 10, 2018 20:41
@TravisEz13 Travis Plunk (TravisEz13) removed this from the 6.1.x-servicing milestone Jul 5, 2019
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…ule path is already in the environment's `PSModulePath` (PowerShell#7727)


This change updates ModuleIntrinsics.GetModulePath to handle the case where the Windows PowerShell module path is already in the environment's PSModulePath or when launched from a different version of PowerShell.

Previously, GetModulePath would append $PSHOME\Modules to the PSModulePath after removing the path for the launching version without considering the Windows PowerShell module path. The result, was the Windows PowerShell modules were found first and loaded incompatible modules; such as the built-in modules.

The change detects the Windows PowerShell module path and inserts $PSHOME\Modules path before it. The new test simulates launching from a different version of pwsh that has already added the Windows PowerShell module path.

Fixes PowerShell#7679
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using PowerShell Core RC-1 as an OpenSSH subsystem on windows breaks core module loading

5 participants