-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix constructing PSModulePath if a sub-path has trailing separator #13147
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
Conversation
|
@SteveL-MSFT are you planning on re-adding a new test? |
src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Outdated
Show resolved
Hide resolved
|
I might have to use a test hook to be able to add a test, need to think more about this. |
|
I suggest add xUnit test. It is more fast and simple. |
iSazonov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downloaded artifact works well.
|
I'm hoping @daxian-dbw will also have a chance to review this this week |
|
@PoshChan please remind me in 10 days |
|
@daxian-dbw please take a moment to review this if you have time |
src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Outdated
Show resolved
Hide resolved
|
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
@SteveL-MSFT If this is still needed, can you resolve the conflicts |
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
🎉 Handy links: |
PR Summary
When constructing PSModulePath, the code checks if one of user path, shared path, or $PSHome path is already part of PSModulePath. The code that does the check trims whitespace and trailing path separator. So if one of those paths match, but actually has whitespace or trailing separator, then the index doesn't take that into account and subsequent paths are inserted in the wrong location creating an invalid path.
The fix is if one of those paths are found, then find the next index of the path separator and insert at that index. If there is no path separator after that index, then it just gets appended to the end.
Spent too much time trying to add a test. The repro requires changing the system environment variable for PSModulePath and a new process to be started so that it's not inherited from an existing PowerShell process. Validated manually.
PR Context
Fix #13025
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.