Update-PSResource tries to reinstall required dependencies
See original GitHub issuePrerequisites
- 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
Issue Analytics
- State:
- Created 2 months ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
When installing an R package, automatically reinstall ...
utils::install.packages seems to be perfectly capable of installing dependencies that are missing. But if there's a dependency that's already ...
Read more >Fix: Couldn't install dependency error | Valorant Guide
Want to play Valorant, but receiving an error about needing to contact support to fix a dependency error? Well, this video covers the...
Read more >Couldn't install Required Dependency
Hey, so I've been trying to install vanguard for the past two-three weeks-ish and everytime I try to install it, it keeps giving...
Read more >How to install only the dependencies of a package?
To install dependencies only, you can use apt-cache show package | grep Depends . This will give you a list of dependencies:
Read more >Problem installing suggested remote dependency ...
It seems that the Remotes section is being ignored and that it is trying to install the dependency from CRAN and thus fails....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@SydneyhSmith here is another example with more detailed reproduction.
Was fixed by PR #1255 I believe