Home > Software engineering >  Cannot install the Azure Az PowerShell module on linux
Cannot install the Azure Az PowerShell module on linux

Time:01-14

I would like to install the Azure Az PowerShell module on Linux following the instructions from the page Install the Azure Az PowerShell module. If I change to a non-root user, and execute the command:

Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

I get

Install-PackageProvider: Unhandled Exception - Message:'The type initializer for 'Microsoft.PackageManagement.Internal.Utility.Extensions.FilesystemExtensions' threw an exception.'
Name:'TypeInitializationException' Stack Trace:'   at Microsoft.PackageManagement.Internal.Utility.Extensions.FilesystemExtensions.MakeSafeFileName(String input) 
...

The

PS /root> $PSVersionTable.PSVersion

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
7      2      1    

PS /home/user> $env:PSModulePath
/home/user/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules

At first sight it looks to me as if there would be a permission problem, but I cannot find the root couse. Any idea?

Thanks in advance!

CodePudding user response:

It is caused by ownership of /tmp/Microsoft.PackageManagement. Only root and the nonroot user who created it were able to install modules.

Deleting this directory mitigates the issue, but, of course, only for the user who creates it.

https://github.com/OneGet/oneget/issues/400

  •  Tags:  
  • Related