chocolatey / home

The place to start for issues with areas of Chocolatey that are infrastructure related, or really any issues could be started here. There is also choco for the CLI client, Chocolatey GUI for the GUI.
Apache License 2.0
29 stars 10 forks source link

Unable to internalize application installers from Chocolatey CDN when doing `choco download` #313

Closed gep13 closed 7 months ago

gep13 commented 7 months ago

Checklist

What You Are Seeing?

When attempting to download (also known an internalize) a package from the Chocolatey Community Repository, the following error is returned:

System.Exception: The remote file either doesn't exist, is unauthorized, or is forbidden for url . The remote server returned an error: (403) Forbidden.

What is Expected?

The internalization process should succeed without error.

How Did You Get This To Happen?

Execute the following command:

choco download GoogleChrome --internalize --source https://community.chocolatey.org/api/v2/

Since this package uses an installer which is cached in the Chocolatey CDN, it will attempt to download the application installer from there, and it will fail to find it, even those it is there.

That is why the 403 error is generated.

System Details

Installed Packages

N/A

Output Log

Chocolatey v1.4.0 Business
Downloading existing package(s) to c:\choco-setup\packages\download
googlechrome v123.0.6312.58 (forced) [Approved]
Found internalizable Chocolatey functions. Inspecting values for remote resources.
Found 'https://dl.google.com/dl/chrome/install/googlechromestandaloneenterprise.msi' for replacement.
Will use download CDN cache instead of original url.
Found 'https://dl.google.com/dl/chrome/install/googlechromestandaloneenterprise64.msi' for replacement.
Will use download CDN cache instead of original url.
Encountered error downloading package googlechrome v:
System.Exception: The remote file either doesn't exist, is unauthorized, or is forbidden for url <REDACTED>. 
  The remote server returned an error: (403) Forbidden.
   at chocolatey.licensed.infrastructure.app.commandresources.RemoteDownloader.download_file(String url, String filePath, String userAgent, Boolean showProgress)
   at chocolatey.licensed.infrastructure.app.commands.ProChocolateyDownloadCommand.process_downloaded_package(IPackage package, String downloadLocation, ChocolateyConfiguration configuration)
   at chocolatey.infrastructure.app.nuget.NugetCommon.<>c__DisplayClass9_0.<GetPackageManager>b__0(Object s, PackageOperationEventArgs e)
   at NuGet.PackageManager.OnInstalled(PackageOperationEventArgs e)
   at NuGet.PackageManager.Execute(IPackage package, IPackageOperationResolver resolver)
   at NuGet.PackageManager.InstallPackage(IPackage package, Boolean ignoreDependencies, Boolean allowPrereleaseVersions)
   at chocolatey.licensed.infrastructure.app.commands.ProChocolateyDownloadCommand.download_packages(String packageName, String packageVersion, String downloadLocation, ChocolateyConfiguration configuration)_

Additional Context

The underlying problem here is a change to the Chocolatey Community Repository which was detailed in our blog post.

One of the changes that was made here was to change how we address Package IDs, and this has had an unintended consequence of breaking how the download URL for application installers is done against the Chocolatey CDN.

┆Issue is synchronized with this Gitlab issue by Unito

gep13 commented 7 months ago

Workaround

A suggested workaround while this problem is worked on would be to use the --skip-download-cache option, to bypass the usage of the Chocolatey CDN.

i.e.

choco download GoogleChrome --internalize --source https://community.chocolatey.org/api/v2/ --skip-download-cache
AdmiringWorm commented 7 months ago

The issue related to this has been resolved and deployed.

Some existing packages may still exhibit this behavior for some time. Please reach out to us in discord, or comment here on this issue with the package ID and Version, and we can resolve it immediately.

joe-malicki commented 7 months ago

Thank you for getting this issue resolved. I was able to successfully internalize the GoogleChrome package. Really appreciate the help!