Repository navigation
Install-PSResource on module "Az" results in error "Could not find file [...] Az.ps1" #873
Copy link
Copy link
Open
Labels
Milestone
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
Installing the Az module using Install-PSResource should successfully install the module, however, it results in a failure.
Install-PSResource -Name Az
However, executing the code below can be used as a workaround that successfully installs the module. The reason is unknown.
Install-PSResource -Name Az -Repository PSGallery
Expected behavior
Successful installationActual behavior
PS> Install-PSResource -Name Az
Install-PSResource: Unable to successfully install package 'Az': 'Could not find file '/var/folders/sx/vwrdwvmn3_q1n854bqt5p2wh0000gn/T/b4a03b2c-92cf-48d4-aca5-9ad29a05f09d/az/1.0.0.5/Az.ps1'.'Error details
PS> Get-Error
Exception :
Type : System.Management.Automation.PSInvalidOperationException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : Unable to successfully install package 'Az': 'Could not find file
'/var/folders/sx/vwrdwvmn3_q1n854bqt5p2wh0000gn/T/b4a03b2c-92cf-48d4-aca5-9ad29a05f09d/az/1.0.0.5/Az.ps1'.'
HResult : -2146233087
CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : InvalidOperation
Message : Unable to successfully install package 'Az': 'Could not find file
'/var/folders/sx/vwrdwvmn3_q1n854bqt5p2wh0000gn/T/b4a03b2c-92cf-48d4-aca5-9ad29a05f09d/az/1.0.0.5/Az.ps1'.'
InnerException :
Type : System.IO.FileNotFoundException
Message : Could not find file
'/var/folders/sx/vwrdwvmn3_q1n854bqt5p2wh0000gn/T/b4a03b2c-92cf-48d4-aca5-9ad29a05f09d/az/1.0.0.5/Az.ps1'.
FileName : /var/folders/sx/vwrdwvmn3_q1n854bqt5p2wh0000gn/T/b4a03b2c-92cf-48d4-aca5-9ad29a05f09d/az/1.0.0.5/Az.ps1
TargetSite :
Name : ThrowExceptionForIoErrno
DeclaringType : Interop, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
MemberType : Method
Module : System.Private.CoreLib.dll
Source : System.Private.CoreLib
HResult : -2147024894
StackTrace :
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share,
FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions,
Func`4 createOpenException)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share,
FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.File.ReadAllLines(String path, Encoding encoding)
at Microsoft.PowerShell.PowerShellGet.UtilClasses.PSScriptFileInfo.TryParseScriptFileContents(String scriptFileInfoPath,
List`1& psScriptInfoCommentContent, List`1& helpInfoCommentContent, List`1& requiresCommentContent, String[]&
remainingFileContent, ErrorRecord& error) in /Users/andrewsuh/PowerShellGet/src/code/PSScriptFileInfo.cs:line 118
at Microsoft.PowerShell.PowerShellGet.UtilClasses.PSScriptFileInfo.TryTestPSScriptFile(String scriptFileInfoPath,
PSScriptFileInfo& parsedScript, ErrorRecord[]& errors, String[]& verboseMsgs) in
/Users/andrewsuh/PowerShellGet/src/code/PSScriptFileInfo.cs:line 305
at Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallHelper.InstallPackage(List`1 pkgsToInstall, String repoName, String
repoUri, PSCredentialInfo repoCredentialInfo, PSCredential credential, Boolean isLocalRepo, ScopeType scope) in
/Users/andrewsuh/PowerShellGet/src/code/InstallHelper.cs:line 577
HResult : -2146233079
TargetObject : Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource
CategoryInfo : InvalidOperation: (Microsoft.PowerShel…s.InstallPSResource:InstallPSResource) [Install-PSResource],
PSInvalidOperationException
FullyQualifiedErrorId : InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource
InvocationInfo :
MyCommand : Install-PSResource
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 6
Line : Install-PSResource -Name Az
PositionMessage : At line:1 char:1
+ Install-PSResource -Name Az
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Install-PSResource
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :Environment data
PS> Get-Module PowerShellGet; $PSVersionTable
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.2.5 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCapa…
Binary 3.0.17 beta17 PowerShellGet {Find-PSResource, Get-PSResource, Get-PSResourceRepository,…
Key : PSVersion
Value : 7.3.0
Name : PSVersion
Key : PSEdition
Value : Core
Name : PSEdition
Key : GitCommitId
Value : 7.3.0
Name : GitCommitId
Key : OS
Value : Darwin 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64
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 : WSManStackVersionVisuals
No response
Reactions are currently unavailable
Activity
anamnavi commentedon Dec 12, 2022
Andrew Suh (@andrewsuh98) thanks for bringing this issue to our attention, we will investigate into it!
alerickson commentedon Dec 29, 2022
I actually can't repro this on my machine. Andrew Suh (@andrewsuh98) could you run
Get-PSResourceRepositoryso we can see what repositories you have registered. Anam Navied (@anamnavi) could you try repro'ing this as well?andrewsuh98 commentedon Jan 4, 2023
alerickson I have not registered the PSGallery as trusted. Is that something that should be done beforehand? Shouldn't it still install the resource after asking the user if it should trust the gallery? Here is my PowerShell output for Get-PSResourceRepository.
anamnavi commentedon Jan 9, 2023
We can add better error handling here for when a .nupkg package is attempted to be installed yet does not contain a .ps1 or .psd1 file (i.e it is not a PowerShell resource).
mgreenegit commentedon Jan 19, 2023
Andrew Suh (@andrewsuh98) the problem is that PSGet is finding NuGet packages from the NuGet feed, and detecting they are not PowerShell content. AFAIK there is no filter in NuGet feeds by type, so this cannot be handled during the search.
I agree the error message can be improved. Could that be a post-GA issue? This does not seem to be blocking.