Skip to content

Update-PSResource tries to reinstall required dependencies #1273

@ThomasNieto

Description

@ThomasNieto

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

Update a module with a required dependency, it is helpful to have a binary module loaded so the files are locked.

Expected behavior

# required module is not installed again

Actual behavior

Update-PSResource anypackage.programs -PassThru
Update-PSResource: Unable to successfully install package 'AnyPackage': 'Cannot remove package path C:\Users\Thomas\Documents\PowerShell\Modules\AnyPackage\0.5.1. The previous package contents have been restored.'
Update-PSResource: Operation is not valid due to the current state of the object.

Error details

ErrorIndex: 0

Exception             :
    Type    : System.InvalidOperationException
    Message : Operation is not valid due to the current state of the object.
    HResult : -2146233079
TargetObject          : Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper
CategoryInfo          : InvalidOperation: (Microsoft.PowerShel…dlets.InstallHelper:InstallHelper) [Update-PSResource],
InvalidOperationException
FullyQualifiedErrorId : InstallPackageTryMoveContentFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource
InvocationInfo        :
    MyCommand        : Update-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 1
    Line             : Update-PSResource anypackage.programs -PassThru
    Statement        : Update-PSResource anypackage.programs -PassThru
    PositionMessage  : At line:1 char:1
                       + Update-PSResource anypackage.programs -PassThru
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Update-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :




   ErrorIndex: 1

Exception             :
    Type           : System.Management.Automation.PSInvalidOperationException
    ErrorRecord    :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Unable to successfully install package 'AnyPackage': 'Cannot remove package path
C:\Users\Thomas\Documents\PowerShell\Modules\AnyPackage\0.5.1. The previous package contents have been restored.'
            HResult : -2146233087
        CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : InvalidOperation
    Message        : Unable to successfully install package 'AnyPackage': 'Cannot remove package path
C:\Users\Thomas\Documents\PowerShell\Modules\AnyPackage\0.5.1. The previous package contents have been restored.'
    InnerException :
        Type           : System.Management.Automation.PSInvalidOperationException
        ErrorRecord    :
            Exception             :
                Type    : System.Management.Automation.ParentContainsErrorRecordException
                Message : Cannot remove package path C:\Users\Thomas\Documents\PowerShell\Modules\AnyPackage\0.5.1.
The previous package contents have been restored.
                HResult : -2146233087
            CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRecordException
            FullyQualifiedErrorId : InvalidOperation
        TargetSite     :
            Name          : DeleteDirectoryWithRestore
            DeclaringType : Microsoft.PowerShell.PSResourceGet.UtilClasses.Utils, Microsoft.PowerShell.PSResourceGet,
Version=0.5.22.0, Culture=neutral, PublicKeyToken=null
            MemberType    : Method
            Module        : Microsoft.PowerShell.PSResourceGet.dll
        Message        : Cannot remove package path C:\Users\Thomas\Documents\PowerShell\Modules\AnyPackage\0.5.1. The
previous package contents have been restored.
        InnerException :
            Type       : System.UnauthorizedAccessException
            TargetSite :
                Name          : DeleteFile
                DeclaringType : System.IO.FileSystem, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e
                MemberType    : Method
                Module        : System.Private.CoreLib.dll
            Message    : Access to the path
'C:\Users\Thomas\Documents\PowerShell\Modules\AnyPackage\0.5.1\AnyPackage.dll' is denied.
            Source     : System.Private.CoreLib
            HResult    : -2147024891
            StackTrace :
   at System.IO.FileSystem.DeleteFile(String fullPath)
   at Microsoft.PowerShell.PSResourceGet.UtilClasses.Utils.DeleteDirectory(String dirPath)
   at Microsoft.PowerShell.PSResourceGet.UtilClasses.Utils.DeleteDirectoryWithRestore(String dirPath)
        Source         : Microsoft.PowerShell.PSResourceGet
        HResult        : -2146233079
        StackTrace     :
   at Microsoft.PowerShell.PSResourceGet.UtilClasses.Utils.DeleteDirectoryWithRestore(String dirPath)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.MoveFilesIntoInstallPath(PSResourceInfo pkgInfo,
Boolean isModule, Boolean isLocalRepo, String dirNameVersion, String tempInstallPath, String installPath, String
newVersion, String moduleManifestVersion, String scriptPath)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.TryMoveInstallContent(String tempInstallPath, ScopeType
scope, Hashtable packagesHash)
    HResult        : -2146233079
TargetObject          : Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource
CategoryInfo          : InvalidOperation: (Microsoft.PowerShel…ts.UpdatePSResource:UpdatePSResource)
[Update-PSResource], PSInvalidOperationException
FullyQualifiedErrorId : InstallPackageFailed,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource
InvocationInfo        :
    MyCommand        : Update-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 1
    Line             : Update-PSResource anypackage.programs -PassThru
    Statement        : Update-PSResource anypackage.programs -PassThru
    PositionMessage  : At line:1 char:1
                       + Update-PSResource anypackage.programs -PassThru
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Update-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

Environment data

beta22

Visuals

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions