Skip to content

Install-PSResource should restore if reinstall fails #498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
PaulHigin opened this issue Sep 30, 2021 · 0 comments
Closed
3 tasks done

Install-PSResource should restore if reinstall fails #498

PaulHigin opened this issue Sep 30, 2021 · 0 comments
Assignees
Labels
Area-Install Issue-Bug Something isn't working Resolution-Fixed Fixed the issue in latest release or PR
Milestone

Comments

@PaulHigin
Copy link
Contributor

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

When I install the Microsoft.PowerShell.SecretStore extension vault module, Install-PSResource also tries to reinstall the Microsoft.PowerShell.SecretManagement module that it depends on, even though the -Reinstall parameter switch is not used.

However, the Microsoft.PowerShell.SecretManagement module is currently loaded and so the reinstall fails because it is a binary cmdlet and the Microsoft.PowerShell.SecretManagement.dll cannot be deleted.

The result is the Microsoft.PowerShell.SecretManagement module is corrupted since all files are deleted except for the one binary.

I feel a reinstall operation should not occur unless specifically specified by the user. Also, and if a reinstall fails we should have a fallback that restores the original installation.

The corruption occurs without any user error, so it is not apparent that SecretManagement is broken until the user tries running one of its commands.

Expected behavior

PS C:\> Get-SecretInfo

Name                 Type         VaultName
----                 ----         ---------
Secret1              SecureString AzKeyVault

PS C:\> Install-PSResource -Name Microsoft.PowerShell.SecretManagement -Repository PSGallery -Scope AllUsers

PS C:\> Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -AllowClobber

Actual behavior

PS C:\> Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -AllowClobber
Register-SecretVault: Could not load and retrieve module information for module: Microsoft.PowerShell.SecretStore with error : The required module 'Microsoft.PowerShell.SecretManagement' is not loaded. Load the module or remove the module from 'RequiredModules' in the file 'C:\Program Files\PowerShell\Modules\Microsoft.PowerShell.SecretStore\1.0.5\Microsoft.PowerShell.SecretStore.psd1'..

Error details

Error occurs because all `Microsoft.PowerShell.SecretManagement` module files are deleted except for the binary file.

Environment data

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     3.0.11     beta       powershellget                       {Find-PSResource, Get-Installed

Visuals

No response

@PaulHigin PaulHigin added the Issue-Bug Something isn't working label Sep 30, 2021
@SydneyhSmith SydneyhSmith added this to the 3.0-Resolved milestone Oct 19, 2021
@SydneyhSmith SydneyhSmith changed the title Install-PSResource corrupts existing dependency module on reinstall Install-PSResource should restore if it fails Oct 19, 2021
@PaulHigin PaulHigin self-assigned this Oct 28, 2021
@PaulHigin PaulHigin changed the title Install-PSResource should restore if it fails Install-PSResource should restore if reinstall fails Nov 3, 2021
@PaulHigin PaulHigin added the Resolution-Fixed Fixed the issue in latest release or PR label Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Install Issue-Bug Something isn't working Resolution-Fixed Fixed the issue in latest release or PR
Projects
None yet
Development

No branches or pull requests

3 participants