Skip to content

Install-PSResource on module "Az" results in error "Could not find file [...] Az.ps1" #873

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 installation

Actual 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  : WSManStackVersion

Visuals

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions