PowerShell / PowerShellGetv2

PowerShellGet is the Package Manager for PowerShell
https://www.PowerShellGallery.com
MIT License
432 stars 138 forks source link

When updating a module with insufficient space left on disk for the operation an error gets thrown about needing administrator rights while the operation is performed as root #653

Open tslothorst opened 4 years ago

tslothorst commented 4 years ago

I am trying to install/upgrade the VMware.PowerCLI on a RHEL 7.8 machine. The module was installed with the AllUsers scope. This results in an error message saying I need administrator privileges to do this. However I am running pwsh as root.

Steps to reproduce

My system has version 11.x of the VMware.PowerCLI present, which was installed with the AllUsers scope. All components therefor are located at /usr/local/share/powershell/Modules

Install-Module -Name VMware.PowerCLI -Scope AllUsers -Force -Verbose

I've also ran Update-Module with the same parameters, this results in the same outcome.

Expected behavior

A succesful upgrade of the module and it's components.

Actual behavior

VERBOSE: Performing the operation "Install-Module" on target "Version '12.0.0.15947286' of module 'VMware.PowerCLI'".
VERBOSE: The installation scope is specified to be 'AllUsers'.
Install-Package: /opt/microsoft/powershell/7/Modules/PowerShellGet/PSModule.psm1:9709
Line |
9709 |  … talledPackages = PackageManagement\Install-Package @PSBoundParameters
     |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Administrator rights are required to install modules in '/usr/local/share/powershell/Modules'. Log on to the computer with an account that has Administrator rights, and then try again, or install
     | '/root/.local/share/powershell/Modules' by adding "-Scope CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).

Output when using Update-Module:

VERBOSE: Performing the operation "Update-Module" on target "Version '11.2.0.12780525' of module 'VMware.PowerCLI', updating to version '12.0.0.15947286'".
VERBOSE: The installation scope is specified to be 'AllUsers'.
Install-Package: /opt/microsoft/powershell/7/Modules/PowerShellGet/PSModule.psm1:13067
 Line |
13067 |  …           $sid = PackageManagement\Install-Package @PSBoundParameters
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | Administrator rights are required to install modules in '/usr/local/share/powershell/Modules'. Log on to the computer with an account that has Administrator rights, and then try again, or install
      | '/root/.local/share/powershell/Modules' by adding "-Scope CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).

Since pwsh is already being run by root it should have all privileges needed to write to the location where the modules are located.

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Linux 3.10.0-1127.18.2.el7.x86_64 PowerShell/PowerShell#1 SMP Mon Jul 20 22:32:16 UTC 2020
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
tslothorst commented 4 years ago

Update: I upgraded the module. The issue appeared to be that for this procedure more space was needed on the lvm where /usr/local/share/powershell/Modules was. The lvm had free space left, but not enough it seems.

The error about administrator rights still is odd and quite misleading here. An insufficient disk space error would feel more logical in this context.

kvprasoon commented 4 years ago

@iSazonov is this issue correct in PowerShell repo or https://github.com/OneGet/oneget

iSazonov commented 4 years ago

@kvprasoon I don't know. We need more investigations. I think PowerShell might throw a too general exception.

kvprasoon commented 4 years ago

This error is anyways coming from PackageManagement module https://github.com/OneGet/oneget/blob/173df840e345d0a753dd0a9dec684e394f1b22ea/src/Microsoft.PackageManagement/resources/Messages.resx

GitHub
OneGet/oneget
PackageManagement (aka OneGet) is a package manager for Windows - OneGet/oneget
iSazonov commented 4 years ago

/cc @alerickson for information.