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

PowerShell Host - Package scripts setting values can affect packages that depend on them #719

Closed
digitaldrummerj opened this issue May 3, 2016 · 22 comments

Comments

@digitaldrummerj
Copy link

digitaldrummerj commented May 3, 2016

What You Are Seeing?

For the AndroidStudio package that I own I am getting the following error with the latest chocolatey version (Chocolatey v0.9.10-beta1-289-g589515c) that is used as part of the automated test environment.

ERROR: Exception calling "GetResponse" with "0" argument(s): "The underlying connection was closed: An unexpected error
occurred on a receive."
 at Get-WebHeaders, C:\ProgramData\chocolatey\helpers\functions\Get-WebHeaders.ps1: line 92
at Get-ChocolateyWebFile, C:\ProgramData\chocolatey\helpers\functions\Get-ChocolateyWebFile.ps1: line 158
at Install-ChocolateyPackage, C:\ProgramData\chocolatey\helpers\functions\Install-ChocolateyPackage.ps1: line 111
at <ScriptBlock>, C:\ProgramData\chocolatey\lib\AndroidStudio\tools\chocolateyInstall.ps1: line 28
at <ScriptBlock>, C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1: line 48
at <ScriptBlock>, <No file>: line 1

This appears to only happen after installing either the JDK7 (Android Studio 1.5 and below) or JDK8 (Android Studio 2.0.0.20) packages that are part of the dependency list. If the correct JDK package is already installed then the AndroidStudio package works just fine.

What is Expected?

Installer to be downloaded and run successfully. It works against the current production version that is available on the web site.

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

Error Repo steps

Use the vagrant test environment to install the latest AndroidStudio version.

choco install -fydv AndroidStudio -version 2.0.0.20

After it download and installed the android-sdk and jdk8 dependencies successfully, it should error trying to download the AndroidStudio install.

How to make it pass

Either ignore the dependencies or install the JDK8 first with choco install -y jdk8. Then run the install for AndroidStudio.

Output Log

Log for failure showing error for install of Android Studio 2.0.0.20 when jdk8 is not already installed. https://gist.github.com/digitaldrummerj/ea0a56072b9a92af7d4b71371152cbd4

Log for successful install of Android Studio 2.0.0.20 when android-sdk and jdk8 are already installed. https://gist.github.com/digitaldrummerj/29a4194f5705db949d658c34696a91d8

Log for successful install of Android Studio 2.0.0.20 using choco 0.9.9.12 without jdk8 or android--sdk installed. https://gist.github.com/digitaldrummerj/c0995757c2e1f005017b62e318ad2eb3

Package Repo

https://github.com/digitaldrummerj-chocolatey/ChocolateyPackages/tree/master/AndroidStudio

Dependencies

JDK8 for Android Studio 2.0.0.20 and JDK8 Package Source

JDK 7 for Android Studio 1.5 and below or JDK7 Package Source

android-sdk or android-sdk Package Source

@digitaldrummerj digitaldrummerj changed the title Beta - issue download installer after JDK dependency installed Beta - error downloading installer after JDK dependency installed May 3, 2016
@ferventcoder
Copy link
Member

When you say this works against the current production version (0.9.9.12), do you mean that it works with the test environment with the current production version?

@ferventcoder
Copy link
Member

Or are you seeing these errors completely outside of the test environment?

@digitaldrummerj
Copy link
Author

for the current prod environment 0.9.9.12 I ran it both on the vagrant test environment as well as a Windows 8.1 machine that I have.

I have not personally tried the beta version outside of the vagrant test environment.

@ferventcoder
Copy link
Member

I don't see a log for 0.9.9.12 from above. Do you have that gist as well?

@digitaldrummerj
Copy link
Author

just added the link to the gist log for choco 0.9.9.12 to the initial comment

@ferventcoder
Copy link
Member

Thanks!

@ferventcoder
Copy link
Member

Do you believe that this is a gating issue?

@digitaldrummerj
Copy link
Author

Since we do not know what is causing it or really how to work around it without manually installing dependencies, then to me it is gating. I don't know if it is because both JDK7 and 8 use custom download logic to set requires cookies values that is causing the issues or what exactly is causing the issue.

@ferventcoder
Copy link
Member

I put this on the 0.9.10 release for now so that it is at least evaluated and a reason can be determined.

@digitaldrummerj
Copy link
Author

Did I see that the new version allows custom cookies/headers to be set when it tries to download a file? If so, I could try to re-write the JDK7 package to use that and see if it fixes the issue.

@ferventcoder
Copy link
Member

It's a start, but I'm still concerned the other should work.

@ferventcoder
Copy link
Member

Do we think this is only when it is a dependency? I just attempted with the latest beta and all was fine.

Then I did it with the dependencies and it broke.

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } Tell me why you set this.

@digitaldrummerj
Copy link
Author

The JDK7 package was abandoned and when I took over as maintainer it was already in the install script. So not sure why it is set.

@ferventcoder
Copy link
Member

Fair statements. What I've gathered so far - installs work when separate (like you mentioned). Something in the first package script is messing up the second package.

@ferventcoder
Copy link
Member

bumping the priority on this.

@ferventcoder ferventcoder changed the title Beta - error downloading installer after JDK dependency installed PowerShell Host - Package scripts setting values can affect packages that depend on them May 26, 2016
@digitaldrummerj
Copy link
Author

commenting out the [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } line fixes the issues with the dependency.

@ferventcoder
Copy link
Member

That will save me a bit of time - now I need to adjust scripts for isolation.

@digitaldrummerj
Copy link
Author

Figure out what that line of code is doing. It is used to deal with invalid, untrusted or expired SSL certificates. So not sure why we ever needed it. It only affects the current AppDomain, e.g. the current Powershell process. Quit powershell and restart it and it is good again. Supposedly setting the property to $null is suppose to make it work the right way again. Haven't tried that though.

@digitaldrummerj
Copy link
Author

just validated that setting [System.Net.ServicePointManager]::ServerCertificateValidationCallback = $null after downloading JDK8 installer fixed the issue with the dependencies.

@ferventcoder
Copy link
Member

@digitaldrummerj it's the AppDomain isolation I'm talking about. Internal Host means everything runs in same AppDomain.

@ferventcoder
Copy link
Member

I knew what the code was doing, sorry I should have stated what the purpose of it was to save you from having to look it up.

@digitaldrummerj
Copy link
Author

still was good to figure out what it was actually doing and how to fix it within the package. I submitted a pull request to JDK8 package and I will be uploading a new JDK7 package soon with the fix of setting it to $null.

@ferventcoder ferventcoder modified the milestones: 0.9.10.1, 0.9.10 May 29, 2016
@ferventcoder ferventcoder modified the milestones: 0.9.10.1, 0.9.10.2, 0.9.10.3, 0.9.10.4, 0.9.10.5 Jun 17, 2016
ferventcoder added a commit that referenced this issue Sep 12, 2016
If the server certificate validation callback is set in
ServicePointManager, reset it to null with a warning.
ferventcoder added a commit that referenced this issue Sep 12, 2016
* stable: (24 commits)
  (GH-839) Switch to apply package parameters to dependent packages
  (maint) formatting methods / parameters in calls
  (GH-958) If SSLv3 in Posh v2 Fails, Use Original
  (GH-746) Use HTTPS if available when HTTP url
  (GH-957) Skip Get-WebFileName When FTP
  (GH-948) Ensure passwords / keys are not logged
  (GH-952) Get-ChocolateyWebFile enhancements
  (doc) update generated docs
  (maint) formatting
  (docs) move GenerateDocs.ps1 / update
  (GH-932) Do not set unknown checksum to 'md5'
  (GH-719) Reset ServerCertificateValidationCallback
  (GH-305) add MSP/MSU installer types
  (GH-305) update exitcodes to long
  (GH-954) Pending fails when lib does not exist
  (GH-950) Install-ChocolateyPackage - UseOriginalLocation
  (maint) formatting
  (GH-922) Automatically determine checksum type
  (maint) fixes for shimgen
  (GH-948) Do not log sensitive arguments
  ...
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

3 participants