Install-Module: Cannot find path ..\AppData\Local\Temp
woter1832 opened this issue · 3 comments
Steps to reproduce
Install-Module `
-Name "MyModule" `
-Repository "My AzDO feed name" `
-Scope AllUsers `
-RequiredVersion "1.2.3" `
-SkipPublisherCheck `
-Force `
-Confirm:$false `
-Credential $credsVSTS `
-VerboseExpected behaviour
Install the module
Actual behaviour
PS C:\Windows\system32> C:\Users\some_user\source\ARCOTEK\arc.service.ps.modules\PSAzDOTools\install.ps1
VERBOSE: Repository details, Name = 'ArcGallery', Location = 'https://pkgs.dev.azure.com/AzDOOrg/_packaging/ArcGallery/nuget/v2'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'ArcGallery', Location = 'https://pkgs.dev.azure.com/AzDOOrg/_packaging/ArcGallery/nuget/v2'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Source 'ArcGallery' already registered on this computer.
VERBOSE: Repository details, Name = 'ArcGallery', Location = 'https://pkgs.dev.azure.com/AzDOOrg/_packaging/ArcGallery/nuget/v2'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'ArcGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://pkgs.dev.azure.com/AzDOOrg/_packaging/ArcGallery/nuget/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://pkgs.dev.azure.com/AzDOOrg/_packaging/ArcGallery/nuget/v2/FindPackagesById()?id='PSAzDOTools'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'PSAzDOTools'.
VERBOSE: Performing the operation "Install-Module" on target "Version '1.2.2320' of module 'PSAzDOTools'".
VERBOSE: The installation scope is specified to be 'AllUsers'.
VERBOSE: The specified module will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'PSAzDOTools' with version '1.2.2320' from the repository 'https://pkgs.dev.azure.com/AzDOOrg/_packaging/ArcGallery/nuget/v2'.
VERBOSE: Searching repository 'https://pkgs.dev.azure.com/AzDOOrg/_packaging/ArcGallery/nuget/v2/FindPackagesById()?id='PSAzDOTools'' for ''.
VERBOSE: InstallPackage' - name='PSAzDOTools', version='1.2.2320',destination='C:\Users\some_user\AppData\Local\Temp\1126213012'
VERBOSE: DownloadPackage' - name='PSAzDOTools', version='1.2.2320',destination='C:\Users\some_user\AppData\Local\Temp\1126213012\PSAzDOTools.1.2.2320\PSAzDOTools.1.2.2320.nupkg',
uri='https://pkgs.dev.azure.com/AzDOOrg/_packaging/ArcGallery/nuget/v2?id=psazdotools&version=1.2.2320'
VERBOSE: Downloading 'https://pkgs.dev.azure.com/AzDOOrg/_packaging/ArcGallery/nuget/v2?id=psazdotools&version=1.2.2320'.
VERBOSE: Completed downloading 'https://pkgs.dev.azure.com/AzDOOrg/_packaging/ArcGallery/nuget/v2?id=psazdotools&version=1.2.2320'.
VERBOSE: Completed downloading 'PSAzDOTools'.
VERBOSE: Hash not found for the package 'PSAzDOTools'.
VERBOSE: InstallPackageLocal' - name='PSAzDOTools', version='1.2.2320',destination='C:\Users\some_user\AppData\Local\Temp\1126213012'
VERBOSE: Validating the 'PSAzDOTools' module contents under 'C:\Users\some_user\AppData\Local\Temp\1126213012\PSAzDOTools.1.2.2320' path.
PackageManagement\Install-Package : Cannot find the path 'C:\Users\some_user\AppData\Local\Temp\1126213012\PSAzDOTools.1.2.2320\PSAzDOTools.psd1' because it does not exist.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9711 char:34
+ ... talledPackages = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : PathNotFound,Test-ValidManifestModule,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
What is it trying to do with ..\AppData\Local\Temp\..? Why does it need that path? This has always worked in the past.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.1151
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1151
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1> Get-Module -ListAvailable PowerShellGet,PackageManagement
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.4.7 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script 2.2.5 PowerShellGet {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}> Get-PackageProvider -ListAvailable
Name Version DynamicOptions
---- ------- --------------
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
NuGet 3.0.0.1 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet 2.2.5.0 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Filter, Tag, Incl...
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponentAs per normal, it was me!
I was using the wrong pipeline, designed to package for Chocolatey as opposed to PowerShellGet. This meant the NuPkg didn't have the .psd1 file in the root of the package, so it couldn't find the .psd1 file.
However, I'm not closing this as I would like to know why it is trying to use ..\AppData\Temp\... I would also recommend a better error message.
Thanks @woter1832! It is using ..\AppData\Local\Temp\.. as a temporary install location and once it validates the files it is then moved to the respective $env:PSModulesPath location. Some of the error messaging in v2 is not that great, we are improving error messaging more in PowerShellGet v3, thank you for the feedback!
We've had a similar problem to this one. Whilst running Install-Package -Source -Name we get the error
install-Package : Cannot find the path 'C:\Users\<user>\AppData\Local\Temp\1058270344\<OurPackage>\<OurPackage>.psd1' because it does not exist.
We found that if you provide the source as a URI rather than a PackageProvider (the URI being the same as the package provider registration) then the install-package works OK. Maybe something to do with it going through a PackageProvider registration?
(With PowerShellGet 2.2.5 and 2.2.5.1)