choco icon indicating copy to clipboard operation
choco copied to clipboard

Rerunning Install Script after reboot should not be necessary

Open JPRuskin opened this issue 2 years ago • 9 comments

Checklist

  • [X] I have verified this is the correct repository for opening this issue.
  • [X] I have verified no other issues exist related to my request.

Is Your Feature Request Related To A Problem? Please describe.

The user-experience when installing Chocolatey on a system that lacks dotnet 4.8 could be improved, and our most used flow requires:

  • Running the install script
  • Dotnet 4.8 being installed
  • Being prompted to reboot
  • Rebooting
  • Running the install script again

This is less than ideal, introduces complexity, and could be improved.

Describe The Solution. Why is it needed?

I would suggest, given that the rest of the install seems to work fine without the reboot, that we proceed with the rest of the installation after the dotnet installation.

This would result in a system that, though needing a reboot, will come up from the reboot with a fully functional Chocolatey install - and no further required steps.

Given that Chocolatey itself prevents users from running any command beyond -v/--version when 4.8 is not installed correctly (and has an appropriately explicit error message), this should not introduce a particularly awful level of confusion.

It shouldn't break any automation, either, as the install is fairly idempotent so anyone who already is running the script, rebooting, and running it again should just work.

This is also, to me, far closer to other software installations - and my expectations of running an install script.

Additional Context

Example of a modified install proceeding after dotnet is installed (but no reboot): image

Example of the current error message produced when there has not been a reboot: image

Related Issues

No response

JPRuskin avatar Sep 20 '23 13:09 JPRuskin

I believe when I originally spoke to people about this I suggested that we could make it non-default behaviour, behind a switch or environment variable (similar to using Windows compression instead of 7zip), but as I have encountered this issue more I have decided that this is not a breaking change and is fine to be the default behaviour.

We could throw at the end of the install script, though, if we really wanted to indicate that something went wrong. I would suggest we follow msiexec, for instance, though, and exit without throwing.

JPRuskin avatar Sep 20 '23 16:09 JPRuskin

I'm encountering this problem with a client at the moment. They use VMs based on Windows Server 2019 Datacenter edition. Chocolatey is deployed via PowerShell DSC but installation fails since Chocolatey 2.x for this exact reason. Rebooting and trying again hasn't proven a reliable solution. Merging the related PR should solve our issues.

leonmelein avatar Dec 21 '23 11:12 leonmelein

@leonmelein have you tried installing .NET 4.8, rebooting and then installing Chocolatey CLI?

Rebooting and trying again hasn't proven a reliable solution.

Can you elaborate on this?

pauby avatar Dec 21 '23 11:12 pauby

@pauby The Chocolatey installation is performed by means of a custom script extension in Azure, performed after deployment of the VM. The extension pull the latest version of Chocolatey from an internal repository and runs the install script.

Custom script extensions cannot handle reboots in Azure, as per Microsoft:

Don't put restarts inside the script. This action causes problems with other extensions that are being installed, and the extension doesn't continue after the restart.

Given the circumstances at this client, I cannot change the way the machines are provisioned, e.g. providing a custom image or using a more recent Windows Server image.

Hope that gives a little more clarity. When I perform the installation manually, everything works as advertised.

leonmelein avatar Dec 21 '23 12:12 leonmelein

@leonmelein that helps.

If you install. NET 4.8 you need to reboot before you can install Chocolatey CLI (or anything as .NET 4.8 requires a reboot too be installed). If you install Chocolatey CLI then it will install .NET 4.8 and require you to reboot before you can use it.

In both situations you need to reboot, which you can't do.

Can you explain how this PR will fix your situation? On the surface it sounds like the requirement for .NET 4.8, however it's done, is going to have the same result?

pauby avatar Dec 21 '23 12:12 pauby

Yes, eventually a reboot will be necessary. If the Chocolatey installation itself isn't held up by the pending reboot, I could make sure the reboot happens at the very end of the VM deployment. That would be by using the AzureCLI@2 task and the az vm restart command.

At the moment, this isn't an option since there are several custom script extensions being executed sequentially directly after the deployment of the VM. This is managed completely by Azure and I cannot mix in an Azure CLI command while these extensions are running.

leonmelein avatar Dec 21 '23 13:12 leonmelein

This maybe a dumb question.

Could you not install .NET 4.8 as part of the VM deployment, then reboot? Then as part of the provisioning (which I assume happens afterwards) install Chocolatey CLI, software, etc.?

pauby avatar Dec 21 '23 13:12 pauby

That's not a dumb question. The issue with these custom script extensions is that they're executed as part of the deployment, not as separate actions. In theory we might be able to refactor this process and use a different approach, but given we're using scripts provided by another internal team that would require significant effort and coordination.

leonmelein avatar Dec 21 '23 14:12 leonmelein

Thanks for that.

Just to set expectations, any change to the Chocolatey CLI installation script goes through extensive testing with all products that use it. So this isn't something that is likely to be implemented soon.

pauby avatar Dec 21 '23 14:12 pauby

:tada: This issue has been resolved in version 2.3.0 :tada:

The release is available on:

Your GitReleaseManager bot :package: :rocket:

choco-bot avatar Jun 05 '24 13:06 choco-bot