Skip to content

Fix System32 module path duplication - #7414

Merged
Dongbo Wang (daxian-dbw) merged 6 commits into
PowerShell:masterfrom
rjmholt:fix-powershell-path-duplication
Aug 3, 2018
Merged

Dongbo Wang (daxian-dbw) merged 6 commits into
PowerShell:masterfrom
rjmholt:fix-powershell-path-duplication

Conversation

@rjmholt

Copy link
Copy Markdown
Collaborator

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

@iSazonov Ilya (iSazonov) left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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.

@rjmholt Rob Holt (rjmholt) Aug 1, 2018 •

Copy link
Copy Markdown
Collaborator Author

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
Copy Markdown

Restarted travis-ci test run.

@anmenaga Andrew (anmenaga) left a comment

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Dongbo Wang (daxian-dbw) merged commit dbdcf6e into PowerShell:master Aug 3, 2018
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
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