Repository navigation
Closed
Labels
Area-PowerShellGetspecific to PowerShellGet moduleIssue-BugIssue has been identified as a bug in the product
Description
This issue got reported in #1184.
As per #1184, PowerShellGet in PowerShell Core on Windows should install the modules to the following locations.
CurrentUser scope: ~\Documents\PowerShell\Modules - User documents module location for PowerShell Core
AllUsers scope: %ProgramFiles%\PowerShell<version>\Modules - Module path for the specific instance of PowerShell Core that is running.
Similar locations for scripts:
CurrentUser scope: ~\Documents\PowerShell\Scripts
AllUsers scope: %ProgramFiles%\PowerShell<version>\Scripts
Steps to reproduce
PS C:\Program Files\PowerShell\6.0.0.9> ls C:\Users\masae\Documents\PowerShell\Modules
PS C:\Program Files\PowerShell\6.0.0.9> ls C:\Users\masae\Documents\WindowsPowerShell\Modules\
PS C:\Program Files\PowerShell\6.0.0.9> (get-command Install-Module).Module.Path
C:\program files\powershell\6.0.0.9\Modules\PowerShellGet\PSModule.psm1
PS C:\Program Files\PowerShell\6.0.0.9> Install-Module zlocation -Scope CurrentUser
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
PS C:\Program Files\PowerShell\6.0.0.9> ls C:\Users\masae\Documents\PowerShell\Modules
PS C:\Program Files\PowerShell\6.0.0.9> ls C:\Users\masae\Documents\WindowsPowerShell\Modules\
Directory: C:\Users\masae\Documents\WindowsPowerShell\Modules
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2016-08-21 4:27 PM ZLocation
PS C:\Program Files\PowerShell\6.0.0.9>
Expected behavior
As per #1184, PowerShellGet on Windows PowerShell Core should install the modules to the following locations.
CurrentUser scope: ~\Documents\PowerShell\Modules - User documents module location for PowerShell Core
AllUsers scope: %ProgramFiles%\PowerShell<version>\Modules - Module path for the specific instance of PowerShell Core that is running.
Similar locations for scripts:
CurrentUser scope: ~\Documents\PowerShell\Scripts
AllUsers scope: %ProgramFiles%\PowerShell<version>\Scripts
Actual behavior
Captured in the repro steps.
Environment data
PS C:\Program Files\PowerShell\6.0.0.9> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-alpha
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
BuildVersion 3.0.0.0
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSEdition Core
CLRVersion
GitCommitId v6.0.0-alpha.9-107-gfb3d929e15c51028cf8d6ff6afd0dd19f288e9fd
WSManStackVersion 3.0
Metadata
Metadata
Assignees
Labels
Area-PowerShellGetspecific to PowerShellGet moduleIssue-BugIssue has been identified as a bug in the product
Activity
kilasuit commentedon Aug 22, 2016
This brings an issue when running PowerShell 6 in side by side mode on windows due to the fact that this would require a change to PSModulePath for the modules to be found by Get-Module -ListAvailable
Take this example
I install modules from the PowerShell Gallery when running PowerShell v 5.1 (Windows 10 AU +) which installs the module to C:\Program Files\WindowsPowerShell\Modules which is a path in my PSModulePath Environment Variable
Now when I load Powershell 6x it will be able to find modules in that path which I do not want
So to get round this I have to enforce that PSModulePath only has the C:\Program Files\PowerShell\Modules location defined as not to load any modules that require the full .NET framework.
So I would be suggestive of a breaking change for PowerShell Core and implement a completely new PSCoreModulePath env variable which would allow co-existence to occur with no issues to the underlying WindowsPowerShell install on a machine.
masaeedu commentedon Aug 22, 2016
Ryan Yates (@kilasuit) When you load PS6 it will not be able to find modules in
C:\Program Files\WindowsPowerShell\Modules, because the PSModulePath is not changing. The location to which PowershellGet installs modules in PS6 is changing.kilasuit commentedon Aug 24, 2016
Asad Saeeduddin (@masaeedu) seems between 6.0.0.8 & 6.0.0.9 the PSModulePath has been changed to not load the actual entries that are listed in the Environmental variable which I seem to have missed where this change came in (hence before saying that I needed to edit the PSModulePath)
For example see how my PSModulePath across 5.1.14905.1000 (left), 6.0.0.8 (middle) & 6.0.0.9 (right) are different as below
However it brings the question as I couldn't work it out but what change was it that took place between 6.0.0.8 & 6.0.0.9 that modifies how PSModulePath env variable is populated.