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

Update setting PSModulePath to concatenate the process + machine env var by SteveL-MSFT · Pull Request #11276 · PowerShell/PowerShell · GitHub

Update setting PSModulePath to concatenate the process + machine env var - #11276

Merged
Dongbo Wang (daxian-dbw) merged 5 commits into
PowerShell:masterfrom
SteveL-MSFT:psmodulepath-update
Dec 10, 2019
Merged

Update setting PSModulePath to concatenate the process + machine env var#11276
Dongbo Wang (daxian-dbw) merged 5 commits into
PowerShell:masterfrom
SteveL-MSFT:psmodulepath-update

Conversation

Steve Lee (SteveL-MSFT) commented Dec 6, 2019
edited
Loading

Copy link
Copy Markdown
Member

PR Summary

The problem is that Windows treats User scope env vars as the preferred value over Machine scope env vars. So if a user has PSModulePath defined in their User scope, then the Machine scope one isn't used. In other words, the Process scope env var is the same as the User scope env var. However, Windows treats PATH differently in that it concatenates PATH from User scope with PATH from Machine scope. PSModulePath works like PATH so it should also do the same thing that Windows doesn't automatically do. You can observe this with just cmd.exe.

The fix here is to start with env var inherited by Process. If it's the same as the one in User scope, it means the user hasn't modified it and it's incomplete, so we append the Machine scope one. If it's different, we just use the Process one.

Also fixed an issue where PSModulePath was a single path without a path separator.

PR Context

Fix #11172

PR Checklist

Copy link
Copy Markdown
Member Author

Codacy is confused about the ternary operator, we should probably update the PSSA rule

Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Dec 6, 2019

Copy link
Copy Markdown
Member Author

PoshChan-Bot (@PoshChan) please retry windows

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), successfully started retry of PowerShell-CI-Windows

…cs.cs

Co-Authored-By: Dongbo Wang <dongbow@microsoft.com>
Dongbo Wang (daxian-dbw) merged commit 20a236b into PowerShell:master Dec 10, 2019
Steve Lee (SteveL-MSFT) deleted the psmodulepath-update branch December 10, 2019 00:25
Dongbo Wang (daxian-dbw) added CL-Engine Indicates that a PR should be marked as an engine change in the Change Log and removed CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log labels Dec 10, 2019

Copy link
Copy Markdown

🎉v7.0.0-rc.1 has been released which incorporates this pull request.:tada:

Handy links:

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modules under C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules not found with PowerShell 7-preview.6

6 participants


Back | FazBrowse Home | New Git URL