9

Chocolatey installation started to fail last week. Dockerfile starts with

FROM python:3.8.2-windowsservercore-ltsc2016
SHELL ["powershell","-Command"]
RUN "Set-ExecutionPolicy Bypass -Scope Process -Force; [Net.ServicePointManager]::SecurityProtocol = 'tls12'; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"

and log says:

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.
Getting Chocolatey from https://community.chocolatey.org/api/v2/package/chocolatey/2.0.0.
Downloading https://community.chocolatey.org/api/v2/package/chocolatey/2.0.0 to C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip
Not using proxy.
Extracting C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip to C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall
Installing Chocolatey on the local machine
The registry key for .Net 4.8 was not found or this is forced

Downloading 'https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/8494001c276a4b96804cde7829c04d7f/ndp48-x86-x64-allos-enu.exe' to 'C:\Users\ContainerAdministrator\AppData\Local\Temp\ndp48-x86-x64-allos-enu.exe' - the installer is 100+ MBs, so this could take a while on a slow connection.

Installing 'C:\Users\ContainerAdministrator\AppData\Local\Temp\ndp48-x86-x64-allos-enu.exe' - this may take awhile with no output.

.NET Framework 4.8 was installed, but a reboot is required. 

Please reboot the system and try to install/upgrade Chocolatey again.

How to solve this issue?

Ľubomír Mlích
  • 649
  • 6
  • 12

3 Answers3

6

Specifying older chocolatey version in Dockerfile seems to help workaround the issue

ENV chocolateyVersion=1.4.0

as of previous week this is the version which was downloaded as latest.

Ľubomír Mlích
  • 649
  • 6
  • 12
2

The requirement for .NET Framework 4.8 is something which has been talked about for a while, and something which is mentioned in both the release notes, and the upgrade guide.

https://docs.chocolatey.org/en-us/choco/release-notes#may-31-2023

Upgrade to target version 4.8 of the .NET Framework - see #2738.

https://docs.chocolatey.org/en-us/guides/upgrading-to-chocolatey-v2-v6#net-framework-4.8-required

We recommend you install .NET Framework 4.8 and reboot, before installing or upgrading to Chocolatey CLI v2.0.0. If you are installing Chocolatey in a Docker container, please use an image that already has .NET 4.8 installed or use the official Chocolatey CLI Docker image.

You can see the base image that is used for the official Chocolatey Docker Image here:

https://github.com/chocolatey/choco/blob/develop/docker/Dockerfile.windows#L1

FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2016
Gary Ewan Park
  • 17,610
  • 5
  • 42
  • 60
1

For those running into this same issue when installing choco via PowerShell on a machine that cannot be upgraded to .NET 4.8 yet, add this to your PowerShell script to install the prior version of choco and avoid the new .NET 4.8 requirement:

$env:chocolateyVersion = '1.4.0'

Then also make sure you do not have this line later in your script, or else it will upgrade to choco 2.0 and install .NET 4.8

choco upgrade chocolatey -y -r
BateTech
  • 5,780
  • 3
  • 20
  • 31
  • 1
    Thank you! Running into an issue with automated deployments on headless machines, and this solved it for us. – qJake Jun 30 '23 at 21:12