Skip to content

Fix System32 module path duplication #7414

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

Conversation

rjmholt
Copy link
Collaborator

@rjmholt rjmholt commented Jul 31, 2018

PR Summary

Resolves #7327. PowerShell Core subprocesses will only append the System32 module path to the PSModulePath when it is not already present.

PR Checklist

@rjmholt rjmholt requested a review from BrucePay as a code owner July 31, 2018 18:31
Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

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

With one minor comment

pwsh.exe -C '$null = $env:PSModulePath -match ([regex]::Escape((Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules"))); $matches.Count'
}

$sys32ModPathCount -le 1 | Should -BeTrue
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should it always be 1?
We could use Should -BeLessOrEqual.

Copy link
Collaborator Author

@rjmholt rjmholt Aug 1, 2018

Choose a reason for hiding this comment

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

Good thought! Will fix

@anmenaga
Copy link

anmenaga commented Aug 1, 2018

Restarted travis-ci test run.

Copy link

@anmenaga anmenaga left a comment

Choose a reason for hiding this comment

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

LGTM

Restore-ModulePath
}

It "Allows Windows PowerShell subprocesses to call `$PSHome modules still" -Skip:(-not $IsWindows) {
Copy link
Member

Choose a reason for hiding this comment

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

-Skip:(-not $IsWindows) shouldn't be needed here as you have $PSDefaultParameterValues set at the beginning.

It "Allows Windows PowerShell subprocesses to call `$PSHome modules still" -Skip:(-not $IsWindows) {
$errors = powershell.exe -Command "Get-ChildItem" 2>&1 | Where-Object { $_ -is [System.Management.Automation.ErrorRecord] }
$errors | Should -Be $null
It "Allows PowerShell Core 6 subprocesses to call core modules" -Skip:(-not $IsWindows) {
Copy link
Member

Choose a reason for hiding this comment

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

same here.

@daxian-dbw daxian-dbw merged commit dbdcf6e into PowerShell:master Aug 3, 2018
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.

System32 module path is added repeatedly in subprocesses
4 participants