Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chocolateyProxyLocation stopped working when installing choco #4

Closed
EricHripko opened this issue Feb 9, 2021 · 4 comments
Closed

Comments

@EricHripko
Copy link

EricHripko commented Feb 9, 2021

What You Are Seeing?

Chocolatey installer no longer uses proxies even though chocolateyProxyLocation is set.
This leaves chocolatey installation in an unfinished/broken state where the only thing that happens is the creation of an empty C:\ProgramData\Chocolatey\lib\chocolatey folder. See related issue here: #3.

What is Expected?

Chocolatey installer to use proxies when chocolateyProxyLocation is set.

How Did You Get This To Happen? (Steps to Reproduce)

  • Set a proxy to use for installing chocolatey: $env:chocolateyProxyLocation="http://proxy.mycorp.com:81"
  • Run the installer: .\install.ps1

Output Log

Full Log Output

PS C:\Windows\Temp> $env:chocolateyProxyLocation="http://proxy.mycorp.com:81"
PS C:\Windows\Temp> .\install.ps1

Forcing web requests to allow TLS v1.2 (Required for requests to Chocolatey.org)

Getting latest version of the Chocolatey package for download.

Not using proxy.

Exception calling "DownloadString" with "1" argument(s): "Unable to connect to the remote server"

At C:\Windows\Temp\install.ps1:219 char:5



*     (Get-Downloader $url @ProxyConfiguration).DownloadString($url)
*     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  * CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
  * FullyQualifiedErrorId : WebException                                                                                                                                                                                                      Getting Chocolatey from .                                                                                               Downloading  to C:\Users\WDAGUtilityAccount\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip                   Not using proxy.                                                                                                        Exception calling "DownloadFile" with "2" argument(s): "The path is not of a legal form."                               At C:\Windows\Temp\install.ps1:261 char:5                                                                               +     (Get-Downloader $url @ProxyConfiguration).DownloadFile($url, $fil ...                                             +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException                                               + FullyQualifiedErrorId : ArgumentException                                                                                                                                                                                                 Extracting C:\Users\WDAGUtilityAccount\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip to C:\Users\WDAGUtilityAccount\AppData\Local\Temp\chocolatey\chocoInstall                                                                      Microsoft.PowerShell.Archive\Expand-Archive : The path                                                                  'C:\Users\WDAGUtilityAccount\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip' either does not exist or is
not a valid file system path.
At C:\Windows\Temp\install.ps1:517 char:5
*     Microsoft.PowerShell.Archive\Expand-Archive -Path $file -Destinat ...
*     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  * CategoryInfo          : InvalidArgument: (C:\Users\WDAGUt...\chocolatey.zip:String) [Expand-Archive], InvalidOpe
   rationException
  * FullyQualifiedErrorId : ArchiveCmdletPathNotFound,Expand-Archive

Installing Chocolatey on the local machine
& : The term 'C:\Users\WDAGUtilityAccount\AppData\Local\Temp\chocolatey\chocoInstall\tools\chocolateyInstall.ps1' is
not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At C:\Windows\Temp\install.ps1:528 char:3


* & $chocoInstallPS1
*   ~~~~~~~~~~~~~~~~
  * CategoryInfo          : ObjectNotFound: (C:\Users\WDAGUt...ateyInstall.ps1:String) [], CommandNotFoundException
  * FullyQualifiedErrorId : CommandNotFoundException

Ensuring Chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder

Context

The issue appears to be in this bit of code (cannot find the GH repo for this):

    if (-not ($ProxyUrl -and $ProxyCredential)) {
        Write-Host "Not using proxy."
        $downloader.Proxy = $null
    }

This appears to require that both ProxyUrl and ProxyCredential is set despite the code seemingly handling cases where ProxyCredential isn't set. See output from my run below:

    Write-Host $ProxyUrl  # => http://proxy.mycorp.com:81
    Write-Host $ProxyCredential  # => empty string
    Write-Host ($ProxyUrl -and $ProxyCredential)  # => False
    Write-Host $(-not ($ProxyUrl -and $ProxyCredential))  # => True

Changing -not ($ProxyUrl -and $ProxyCredential) to -not ($ProxyUrl -or $ProxyCredential) fixed this issue for me.

┆Issue is synchronized with this GitLab issue by Unito

@gep13 gep13 transferred this issue from chocolatey/choco Feb 9, 2021
@gep13
Copy link
Member

gep13 commented Feb 9, 2021

@EricHripko thanks for reporting this.

I have moved this issue into a different repository for tracking purposes, and we will get this looked at as soon as possible.

@gep13
Copy link
Member

gep13 commented Feb 10, 2021

@EricHripko We have just pushed out a new version of the install.ps1 file. Can you take this for a spin and let us know how you get on? Thanks

@EricHripko
Copy link
Author

Yes, it works for me now - thank you for a prompt fix 🙌

@gep13
Copy link
Member

gep13 commented Feb 10, 2021

Thanks for confirming, I will go ahead and close out this issue.

@gep13 gep13 closed this as completed Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants