You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When executing Find-PSResource on PowerShell Core and 5.1 the $env:PSModulePath is treated as if it is a single path when it contains multiple paths for the different installation scopes.
For example:
PS /> Get-PSResource
Get-PSResource: Could not find a part of the path '/root/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules'.
PS /> dir env:
Name Value
---- -----
PSModulePath /root/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules
The workaround is to set $env:PSModulePath with a single path and retry. For example:
PS /> $env:PSModulePath = '/root/.local/share/powershell/Modules'
PS /> Get-PSResource
Name Version Repository
---- ------- ----------
PowerShellGet 3.0.0-beta10 PSGallery
Expected behavior
PS /> Get-PSResourceName Version Repository---- ------- ----------PowerShellGet 3.0.0-beta10 PSGallery
Actual behavior
PS /> Get-PSResourceGet-PSResource: Could not find a part of the path '/root/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules'.
Error details
Exception : Type : System.IO.DirectoryNotFoundException TargetSite : Name : CreateDirectoryHandle DeclaringType : System.IO.Enumeration.FileSystemEnumerator`1[TResult] MemberType : Method Module : System.IO.FileSystem.dll StackTrace : at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound) at System.IO.Enumeration.FileSystemEnumerator`1.Init() at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized) at System.IO.Enumeration.FileSystemEnumerableFactory.UserDirectories(String directory, String expression, EnumerationOptions options) at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options) at System.IO.Directory.GetDirectories(String path) at Microsoft.PowerShell.PowerShellGet.Cmdlets.GetHelper.ProcessGetParams(String[] name, String version, Boolean prerelease, String path) at Microsoft.PowerShell.PowerShellGet.Cmdlets.GetPSResource.ProcessRecord() at System.Management.Automation.Cmdlet.DoProcessRecord() in /PowerShell/src/System.Management.Automation/engine/cmdlet.cs:line 173 at System.Management.Automation.CommandProcessor.ProcessRecord() in /PowerShell/src/System.Management.Automation/engine/CommandProcessor.cs:line 388 Message : Could not find a part of the path '/root/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules'. Source : System.IO.FileSystem HResult : -2147024893CategoryInfo : NotSpecified: (:) [Get-PSResource], DirectoryNotFoundExceptionFullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.PowerShellGet.Cmdlets.GetPSResourceInvocationInfo : MyCommand : Get-PSResource ScriptLineNumber : 1 OffsetInLine : 1 HistoryId : 18 Line : Get-PSResource PositionMessage : At line:1 char:1 + Get-PSResource + ~~~~~~~~~~~~~~ InvocationName : Get-PSResource CommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, <No file>: line 1
Environment data
ModuleType Version PreRelease Name ExportedCommands
-----------------------------------------------
Script 3.0.0 beta10 PowerShellGet {Find-PSResource,Get-PSResource,Get-PSResourceRepository,Install-PSResource…}
Key : PSVersion
Value : 7.1.4
Name : PSVersion
Key : PSEdition
Value : Core
Name : PSEdition
Key : GitCommitId
Value : 7.1.4
Name : GitCommitId
Key : OS
Value : Linux 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020
Name : OS
Key : Platform
Value : Unix
Name : Platform
Key : PSCompatibleVersions
Value : {1.0,2.0,3.0,4.0…}
Name : PSCompatibleVersions
Key : PSRemotingProtocolVersion
Value : 2.3
Name : PSRemotingProtocolVersion
Key : SerializationVersion
Value : 1.1.0.1
Name : SerializationVersion
Key : WSManStackVersion
Value : 3.0
Name : WSManStackVersion
Visuals
N/A
The text was updated successfully, but these errors were encountered:
Thanks for bringing this to our attention @steveharsant, do you mean to say Get-PSResource in your title and description? We have marked it as a bug and will investigate further.
steveharsant
changed the title
Find-PSResource treats multiple paths set in the environment variable PSModulePath as a single path
Get-PSResource treats multiple paths set in the environment variable PSModulePath as a single path
Sep 30, 2021
Thanks for bringing this to our attention @steveharsant, do you mean to say Get-PSResource in your title and description? We have marked it as a bug and will investigate further.
@StevenBucher98 yes. Apologies. I meant Get not Find! Thank you
Prerequisites
Steps to reproduce
When executing
Find-PSResource
on PowerShell Core and 5.1 the$env:PSModulePath
is treated as if it is a single path when it contains multiple paths for the different installation scopes.For example:
The workaround is to set
$env:PSModulePath
with a single path and retry. For example:Expected behavior
Actual behavior
Error details
Environment data
Visuals
N/A
The text was updated successfully, but these errors were encountered: