-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Update setting PSModulePath to concatenate the process + machine env var #11276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
daxian-dbw
merged 5 commits into
PowerShell:master
from
SteveL-MSFT:psmodulepath-update
Dec 10, 2019
Merged
Update setting PSModulePath to concatenate the process + machine env var #11276
daxian-dbw
merged 5 commits into
PowerShell:master
from
SteveL-MSFT:psmodulepath-update
Dec 10, 2019
Conversation
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
a42a87b
to
83e5286
Compare
83e5286
to
c97a565
Compare
PoshChan
reviewed
Dec 6, 2019
PoshChan
reviewed
Dec 6, 2019
Codacy is confused about the ternary operator, we should probably update the PSSA rule |
PoshChan
reviewed
Dec 6, 2019
@PoshChan please retry windows |
@SteveL-MSFT, successfully started retry of |
iSazonov
reviewed
Dec 6, 2019
src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Outdated
Show resolved
Hide resolved
…cs.cs Co-Authored-By: Ilya <darpa@yandex.ru>
iSazonov
approved these changes
Dec 6, 2019
rjmholt
approved these changes
Dec 6, 2019
daxian-dbw
approved these changes
Dec 9, 2019
src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Outdated
Show resolved
Hide resolved
…cs.cs Co-Authored-By: Dongbo Wang <dongbow@microsoft.com>
TravisEz13
pushed a commit
that referenced
this pull request
Dec 11, 2019
🎉 Handy links: |
22 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.