PowerShellGetv2 icon indicating copy to clipboard operation
PowerShellGetv2 copied to clipboard

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

Open tslothorst opened this issue 4 years ago • 5 comments

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 avatar Sep 01 '20 08:09 tslothorst

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.

tslothorst avatar Sep 01 '20 11:09 tslothorst

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

kvprasoon avatar Sep 02 '20 16:09 kvprasoon

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

iSazonov avatar Sep 03 '20 04:09 iSazonov

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

GitHub
PackageManagement (aka OneGet) is a package manager for Windows - OneGet/oneget

kvprasoon avatar Sep 03 '20 20:09 kvprasoon

/cc @alerickson for information.

iSazonov avatar Sep 04 '20 05:09 iSazonov