OneGet / MicrosoftDockerProvider

Provider to search, save and install Docker
Other
135 stars 56 forks source link

[PROXY] Cannot find path 'C:\[..]\DockerMsftProvider\DockerDefault_DockerSearchIndex.json' because it does not exist. #65

Open tardyp opened 4 years ago

tardyp commented 4 years ago

When trying to install docker behind corporate proxy, I am currently blocked with following errors:

PS C:\Users\Administrator> Find-Package -Name docker -ProviderName DockerMsftProvider  -Proxy http://<redacted> -Verbose
VERBOSE: Using the provider 'DockerMsftProvider' for searching packages.
WARNING: Cannot find path 'C:\Users\Administrator\AppData\Local\Temp\DockerMsftProvider\DockerDefault_DockerSearchIndex.json' because it does not exist.
WARNING: Cannot bind argument to parameter 'downloadURL' because it is an empty string.
WARNING: The property 'AbsoluteUri' cannot be found on this object. Verify that the property exists.
WARNING: The property 'RequestMessage' cannot be found on this object. Verify that the property exists.
Find-Package : No match was found for the specified search criteria and package name 'docker'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Find-Package -Name docker -ProviderName DockerMsftProvider  -Proxy ht ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage

This is on a dev VM, I can switch the same environment to non proxy protected network, and the installation works.

Install-Module -Name DockerMsftProvider -Repository PSGallery-alt -Force -RequiredVersion 1.0.0.8  -Verbose
VERBOSE: Repository details, Name = 'PSGallery-alt', Location = 'https://www.powershellgallery.com/api/v2/'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'PSGallery-alt'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='DockerMsftProvider'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'DockerMsftProvider'.
VERBOSE: Performing the operation "Install-Module" on target "Version '1.0.0.8' of module 'DockerMsftProvider'".
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 'DockerMsftProvider' with version '1.0.0.8' from the repository 'https://www.powershellgallery.com/api/v2/'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='DockerMsftProvider'' for ''.
VERBOSE: InstallPackage' - name='DockerMsftProvider', version='1.0.0.8',destination='C:\Users\Administrator\AppData\Local\Temp\187410397'
VERBOSE: DownloadPackage' - name='DockerMsftProvider', version='1.0.0.8',destination='C:\Users\Administrator\AppData\Local\Temp\187410397\DockerMsftProvider\DockerMsftProvider.nupkg', uri='https://www.powershellgallery.com/api/v2/package/DockerMsftProvider/1.0.0.8'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/DockerMsftProvider/1.0.0.8'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/DockerMsftProvider/1.0.0.8'.
VERBOSE: Completed downloading 'DockerMsftProvider'.
VERBOSE: Hash for package 'DockerMsftProvider' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='DockerMsftProvider', version='1.0.0.8',destination='C:\Users\Administrator\AppData\Local\Temp\187410397'
VERBOSE: Catalog file 'DockerMsftProvider.cat' is not found in the contents of the module 'DockerMsftProvider' being installed.
VERBOSE: Valid authenticode signature found in the file 'DockerMsftProvider.psd1' for the module 'DockerMsftProvider'.
VERBOSE: For publisher validation, current module 'DockerMsftProvider' with version '1.0.0.8' with publisher name 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: For publisher validation, using the previously-installed module 'DockerMsftProvider' with version '1.0.0.8' under 'C:\Program Files\WindowsPowerShell\Modules\DockerMsftProvider\1.0.0.8' with publisher name 'CN=Microsoft Root Certificate Authority 2011,
O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: Authenticode issuer 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of the new module 'DockerMsftProvider' with version '1.0.0.8' matches with the authenticode issuer 'CN=Microsoft Root Certificate
Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of the previously-installed module 'DockerMsftProvider' with version '1.0.0.8'.
VERBOSE: Module 'DockerMsftProvider' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\DockerMsftProvider\1.0.0.8'.
PS C:\Users\Administrator> Find-Package -Name docker -ProviderName DockerMsftProvider  -Proxy http://squid.tls.renault.fr:911 -Verbose
VERBOSE: Using the provider 'DockerMsftProvider' for searching packages.
VERBOSE: Download size: 0.02MB
VERBOSE: Free space on the drive: 199788.78MB
VERBOSE: Downloading https://dockermsft.blob.core.windows.net/dockercontainer/DockerMsftIndex.json to C:\Users\Administrator\AppData\Local\Temp\DockerMsftProvider\DockerDefault_DockerSearchIndex.json
VERBOSE: About to download
VERBOSE: Finished downloading
VERBOSE: Downloaded in 0 hours, 0 minutes, 0 seconds.

Name                           Version          Source           Summary
----                           -------          ------           -------
Docker                         19.03.1          DockerDefault    Contains Docker EE for use with Windows Server.

Note that I use PSGallery-alt as the Register-PSRepository -Default -verbose does not work behind proxy. (that will be another bug report)

WeetA34 commented 3 years ago

Hi, i have the same problem. The proxy is not handled by the provider :(

WeetA34 commented 3 years ago

For now, i did an awfull local fix :) I downloaded the provider zip, expanded it and modified some stuff (see below) Then i copied the files in "C:\Program Files\WindowsPowerShell\Modules\DockerMsftProvider\1.0.0.8" From a new powershell windows, i executed Import-PackageProvider -Name DockerMsftProvider After that, Find-Package and Install-Package work fine

--- C:\Program Files\WindowsPowerShell\Modules\DockerMsftProvider\1.0.0.8\DockerMsftProvider.psm1.orig    2019-08-26 18:49:00.000000000 +0200
+++ C:\Program Files\WindowsPowerShell\Modules\DockerMsftProvider\1.0.0.8\DockerMsftProvider.psm1 2020-09-02 16:48:40.049426000 +0200
@@ -1159,8 +1159,7 @@
         return $Uri
     }

-    $link = $response.Result.RequestMessage.RequestUri
-    $fullUrl = $link.AbsoluteUri
+    $fullUrl = $response.BaseResponse.ResponseUri
     return $fullUrl
 }

@@ -1178,11 +1177,7 @@
         Add-Type -AssemblyName System.Net.Http
     }

-    $httpClient = New-Object System.Net.Http.HttpClient
-    $request = New-Object System.Net.Http.HttpRequestMessage
-    $request.Method = [System.Net.Http.HttpMethod]::Head
-    $request.RequestUri = $Uri
-    $response = $httpclient.SendAsync($request)
+    $response = Invoke-WebRequest -Uri $Uri -Proxy http://proxy:3128 -UseBasicParsing -Method HEAD

     return $response
 }
@@ -1578,8 +1573,8 @@
             Write-Verbose "Downloading $downloadUrl to $destination"
             $startTime = Get-Date
             Write-Verbose "About to download"
-            Invoke-WebRequest -Uri $downloadURL `
-                            -OutFile $destination
+            Invoke-WebRequest -Uri $downloadURL -Proxy http://proxy:3128 -OutFile $destination

             Write-Verbose "Finished downloading"
             $endTime = Get-Date
@@ -1657,7 +1652,7 @@
     if($URL.StartsWith("https://"))
     {
         $response = Get-HttpResponse -Uri $URL
-        $size = $response.Result.Content.Headers.ContentLength
+        $size = $response.BaseResponse.ContentLength
     }

     $parent = Split-Path $Destination -Parent
ramonsmits commented 3 years ago

Had similar issues, solution was [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet
Install-Module DockerMsftProvider -Force
Install-Package Docker -ProviderName DockerMsftProvider -Force

Source: https://stackoverflow.com/questions/45638302/error-trying-to-install-docker-in-windows-server-2016-with-install-module

adeturner commented 1 year ago

Been battling this for an hour or so... if you have a firewall, add dockermsft.azureedge.net to avoid this error

Full list (so far) below... will try to remember to update.

# https://learn.microsoft.com/en-us/powershell/scripting/gallery/getting-started?view=powershell-7.3
onegetcdn.azureedge.net
psg-prod-eastus.azureedge.net
psg-prod-centralus.azureedge.net
az818661.vo.msecnd.net
devopsgallerystorage.blob.core.windows.net
*.powershellgallery.com

# others
config.edge.skype.com
www.msftconnecttest.com
via.placeholder.com
statics-marketingsites-neu-ms-com.akamaized.net
img-prod-cms-rt-microsoft-com.akamaized.net
dockermsft.azureedge.net
pradyumn8181 commented 4 months ago

Hi, I am still gettting the error forInstall-Package Docker -ProviderName DockerMsftProvider -Force as following: `WARNING: Cannot find path 'C:\Users\ADMINI~1\AppData\Local\Temp\DockerMsftProvider\DockerDefault_DockerSearchIndex.json' because it does not exist. WARNING: The remote server returned an error: (400) Bad Request. Install-Package : No match was found for the specified search criteria and package name 'Docker'. Try Get-PackageSource to see all available registered package sources. At line:1 char:1

Can someone suggest something