PowerShell / PowerShell/PSResourceGet

`Get-PSResource` does not search in user context environment variable `PSModulePath`

Open
#889 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Paths feature_request
Dominant language
C#
Stars
576
Forks
114
Avg merge
1d 2h
Merged PRs (30d)
7

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.
Steps to reproduce

PackageManagement, PowerShellGetv2 and PowerShellGet 3.0.18-beta (and prior versions) does not search in directorories specified in user context environmental variable PSModulePath when searching for modules. But at least v3 has a -Path parameter.

Reproduce:

  • Install Az.Accounts to %LOCALAPPDATA%\Microsoft\PowerShell\Modules by using Save-PSResource.
  • Make sure said module is not installed any other places specified in $env:PSModulePath.
    • Or rather any other default locations for PowerShell modules I guess.
  • Make sure %LOCALAPPDATA%\Microsoft\PowerShell\Modules is specified in HKCU:\Environment\PSModulePath, and that PowerShell loaded it into $env:PSModulePath at start. Should also be seen in [System.Environment]::GetEnvironmentVariable('PSModulePath','User').
  • Search for installed modules with PowerShellGet\Get-PSResource -Name 'Az.Accounts'. Result: Not found.
  • Add -Scope 'CurrentUser: Nope, still not found.
  • Add -Path ('{0}\Microsoft\PowerShell\Modules' -f $env:LOCALAPPDATA): Found.

Microsoft.PowerShell.Core\Import-Module and Get-Module works as expected.

Expected behavior
PowerShellGet\Get-PSResource should search in all PSModulePath paths, also those specified in user context environmental variable.
Actual behavior
It does not.
Error details

No response

Environment data
PowerShellGet v3.0.18
Windows PowerShell 5.1 x64 on Windows 10 22H2
Visuals

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Windows PowerShell 5.1 case with Get-PSResource -Name 'Az.Accounts' and a user-context PSModulePath entry. Trace the Get-PSResource search implementation and compare its path handling with the explicit -Path and -Scope CurrentUser cases. Done means resources in user-context PSModulePath locations are found without supplying -Path, with regression coverage for this scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.