Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Allow pwsh to inherit $env:PSModulePath and enable powershell.exe to start correctly#11057

Merged
daxian-dbw merged 10 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
SteveL-MSFT:psmodulepathSteveL-MSFT/PowerShell:psmodulepathCopy head branch name to clipboard
Nov 16, 2019
Merged

Allow pwsh to inherit $env:PSModulePath and enable powershell.exe to start correctly#11057
daxian-dbw merged 10 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
SteveL-MSFT:psmodulepathSteveL-MSFT/PowerShell:psmodulepathCopy head branch name to clipboard

Conversation

@SteveL-MSFT

@SteveL-MSFT SteveL-MSFT commented Nov 13, 2019

Copy link
Copy Markdown
Member

PR Summary

Since $env:PSModulePath is shared across all instances of PowerShell, PowerShell 7 needs to ensure it inherits the env var, but put its paths in front. If starting Windows PowerShell, it will special case powershell.exe and powershell_ise.exe removing PowerShell 7 specific paths creating a new environment for the new process.

This is a breaking change as previously, if pwsh detects it is started from PowerShell, it will clear out $env:PSModulePath and create it from scratch. This change will preserve additions from the system or user env vars but not all have the complicated logic in Windows PowerShell. It will always add user module path, shared module path, and $PSHome module path if it's not already there on startup.

PR Context

Fix #9957
Fix #9921
Fix #7082
Fix #6850
Fix #10620

Implement PowerShell/PowerShell-RFC#233

PR Checklist

@SteveL-MSFT SteveL-MSFT added the Breaking-Change breaking change that may affect users label Nov 13, 2019
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
@SteveL-MSFT SteveL-MSFT added Review - Committee The PR/Issue needs a review from the PowerShell Committee Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Nov 13, 2019
@SteveL-MSFT

Copy link
Copy Markdown
Member Author

@PowerShell/powershell-committee reviewed this and agree to accept these changes for Preview.6

@SteveL-MSFT SteveL-MSFT changed the title Enable Windows PowerShell to run from pwsh Allow pwsh to inherit $env:PSModulePath and enable powershell.exe to start correctly Nov 14, 2019
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs Outdated
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs Outdated
Comment thread src/System.Management.Automation/engine/NativeCommandProcessor.cs Outdated
Comment thread test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Comment thread test/powershell/Modules/Microsoft.PowerShell.Security/certificateCommon.psm1 Outdated
Comment thread test/powershell/engine/Module/ModulePath.Tests.ps1 Outdated
Comment thread test/powershell/engine/Module/ModulePath.Tests.ps1
Co-Authored-By: Robert Holt <rjmholt@gmail.com>
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs Outdated
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs Outdated
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs Outdated
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs Outdated
Comment thread src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs
@SteveL-MSFT

Copy link
Copy Markdown
Member Author

@PoshChan please retry windows

@PoshChan

Copy link
Copy Markdown
Collaborator

@SteveL-MSFT, successfully started retry of PowerShell-CI-Windows

}
}

return string.Join(Path.PathSeparator, modulePathList.ToArray());

@daxian-dbw daxian-dbw Nov 16, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the .ToArray() call is not needed.
I will resolve this in the web ui.

@daxian-dbw daxian-dbw merged commit 2e55303 into PowerShell:master Nov 16, 2019
@rjmholt

rjmholt commented Nov 16, 2019

Copy link
Copy Markdown
Collaborator

Why does this close #7082?

@PaulHigin PaulHigin added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Nov 19, 2019
@PaulHigin PaulHigin added this to the 7.0.0-preview.6 milestone Nov 19, 2019
@ghost

ghost commented Nov 21, 2019

Copy link
Copy Markdown

🎉v7.0.0-preview.6 has been released which incorporates this pull request.:tada:

Handy links:

@rjmholt

rjmholt commented Dec 10, 2019

Copy link
Copy Markdown
Collaborator

FYI this PR did not fix #9921

@SteveL-MSFT SteveL-MSFT deleted the psmodulepath branch June 6, 2020 02:29
1480c1 pushed a commit to m-ab-s/media-autobuild_suite that referenced this pull request Mar 31, 2022
Issue fixed in PowerShell/PowerShell#11057, released in v7.0.0-preview.6, so available from version 7.0.0
Last Powershell version is 5.1 so 6 was already Powershell Core
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking-Change breaking change that may affect users CL-Engine Indicates that a PR should be marked as an engine change in the Change Log Committee-Reviewed PS-Committee has reviewed this and made a decision MustHave

Projects

None yet

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.