Open o-l-a-v opened 1 year ago
Here's the responsible code as far as I can see:
Seems doable to add PSModulePath here?
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && scope is not null) {
Environment.GetEnvironmentVariable(
"PSModulePath",
scope.Value is ScopeType.CurrentUser ? EnvironmentVariableTarget.User : EnvironmentVariableTarget.Machine
);
}
I understand it's more complex than that. One must have tests etc.
Is this one up for grabs, or do you not want environment variable PSModulePath
to have any say?
Edit: Here's a PowerShellers attempt. 😁
Prerequisites
Steps to reproduce
PackageManagement
,PowerShellGetv2
andPowerShellGet
3.0.18-beta (and prior versions) does not search in directorories specified in user context environmental variablePSModulePath
when searching for modules. But at least v3 has a-Path
parameter.Reproduce:
Az.Accounts
to%LOCALAPPDATA%\Microsoft\PowerShell\Modules
by usingSave-PSResource
.$env:PSModulePath
.%LOCALAPPDATA%\Microsoft\PowerShell\Modules
is specified inHKCU:\Environment\PSModulePath
, and that PowerShell loaded it into$env:PSModulePath
at start. Should also be seen in[System.Environment]::GetEnvironmentVariable('PSModulePath','User')
.PowerShellGet\Get-PSResource -Name 'Az.Accounts'
. Result: Not found.-Scope 'CurrentUser
: Nope, still not found.-Path ('{0}\Microsoft\PowerShell\Modules' -f $env:LOCALAPPDATA)
: Found.Microsoft.PowerShell.Core\Import-Module
andGet-Module
works as expected.Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals
No response