chocolatey / cChoco

Community resource to manage Chocolatey
Apache License 2.0
154 stars 99 forks source link

Unable to install chocolatey with cChocoInstaller #179

Closed xadozuk closed 10 months ago

xadozuk commented 10 months ago

Checklist

What You Are Seeing?

Following the change made to the install.ps1 script (https://github.com/chocolatey/home/issues/276), the cChocoInstaller fails to install chocolatey as the folder is created before running the install script!

https://github.com/chocolatey/cChoco/blob/69e258775cb0c719c56236b79dd0ce24fbec6835/DSCResources/cChocoInstaller/cChocoInstaller.psm1#L187-L190

The installation failed with the following error message:

[[cChocoInstaller]ChocoInstall] 
An existing Chocolatey installation was detected. Installation will not continue. This script will not overwrite 
existing installations.

If there is no Chocolatey installation at 'C:\ProgramData\chocolatey', delete the folder and attempt the installation 
again.

Please use choco upgrade chocolatey to handle upgrades of Chocolatey itself.

If the existing installation is not functional or a prior installation did not complete, follow these steps:

 - Backup the files at the path listed above so you can restore your previous installation if needed.

 - Remove the existing installation manually.

 - Rerun this installation script.

 - Reinstall any packages previously installed, if needed (refer to the lib folder in the backup).

Once installation is completed, the backup folder is no longer needed and can be deleted.

What is Expected?

Installation folder should not be created before calling the install script so chocolatey can be installed.

How Did You Get This To Happen?

Try to install chocolatey through DSC using:

cChocoInstaller "ChocoInstall"
{
    installDir = "C:\ProgramData\chocolatey"
 }

System Details

Installed Packages

N/A

Output Log

N/A, chocolatey fail at installation

Additional Context

I will prepare a PR to fix the issue

doherty100 commented 10 months ago

Thank you for opening this issue @xadozuk. I started seeing a similar behavior yesterday on Windows Server 2022 so this is a breaking change. I install chocolatey using Azure Automation Desired State Configuration:

cChocoInstaller 'Chocolatey' {
    InstallDir = 'c:\choco'
    DependsOn = '[xDSCDomainjoin]JoinDomain'
}

When looking at the system I see there is a c:\choco directory, but there are no binaries in it.

I get the following error from Azure Automation Desired State configuration:

{
    "Exception": {
        "Message": "The PowerShell DSC resource \u0027[cChocoInstaller]Chocolatey\u0027 with SourceInfo \u0027::62::9::cChocoInstaller\u0027 threw one or more non-terminating errors while running the Set-TargetResource functionality. These errors are logged to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.",
        "Data": {},
        "InnerException": {
            "ErrorRecord": "The term \u0027Choco\u0027 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.",
            "CommandName": "Choco",
            "WasThrownFromThrowStatement": false,
            "Message": "The term \u0027Choco\u0027 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.",
            "Data": "System.Collections.ListDictionaryInternal",
            "InnerException": null,
            "TargetSite": "System.Management.Automation.CommandInfo LookupCommandInfo(System.String, System.Management.Automation.CommandTypes, System.Management.Automation.SearchResolutionOptions, System.Management.Automation.CommandOrigin, System.Management.Automation.ExecutionContext)",
            "StackTrace": "   at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)\r\n   at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)\r\n   at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)\r\n   at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)\r\n   at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)\r\n   at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)\r\n   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)\r\n   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)",
            "HelpLink": null,
            "Source": "System.Management.Automation",
            "HResult": -2146233087
        },
        "TargetSite": null,
        "StackTrace": null,
        "HelpLink": null,
        "Source": null,
        "HResult": -2146233079
    },
    "TargetObject": null,
    "CategoryInfo": {
        "Category": 7,
        "Activity": "",
        "Reason": "InvalidOperationException",
        "TargetName": "",
        "TargetType": ""
    },
    "FullyQualifiedErrorId": "NonTerminatingErrorFromProvider",
    "ErrorDetails": null,
    "InvocationInfo": null,
    "ScriptStackTrace": null,
    "PipelineIterationInfo": []
}
pauby commented 10 months ago

@xadozuk @doherty100 I wanted to give you a heads-up that I've prioritised this as a high priority, and we are working on it now.

xadozuk commented 10 months ago

@pauby Thanks for the feedback, I have prepared a PR #180 to solve the issue. I tested it in a lab and its working (at least for my use case). I am not sure of the impact that it can have (if some other choco components rely on the folder existing prior to installation).

begna112 commented 10 months ago

Will a new version of cChoco be released to support this fix?

doherty100 commented 10 months ago

@pauby suggest you keep this open until a new release is published given the scope and impact of this issue.

gep13 commented 10 months ago

@doherty100 said... @pauby suggest you keep this open until a new release is published given the scope and impact of this issue.

The process that we follow is one that when the code that fixing the issue has been merged, the issue is closed. The issue will then appear within a milestone, which is then closed once things have been published.

This is the process that we follow across all of the Chocolatey Product Repositories.

jackmtpt commented 10 months ago

@gep13 that process works if you are also automatically publishing releases (or even pre-release packages). As it is, the cChoco module is unusable (due to what seems like a pointless fix in the first place, which wasn't properly tested). Since this has been tagged as a high priority issue, is there a published timeline somewhere of how long it will take before a release is published after the fix has been merged?

pauby commented 10 months ago

@jackmtpt I appreciate you don't agree with the process, but that is the process we use.

I've added the 4 - Done label, as this was missing from the issue. Once it has been released, we will add the 5 - Released label.

due to what seems like a pointless fix in the first place, which wasn't properly tested

With all due respect to you, you don't have information to make a judgement on whether the fix was pointless, or what testing was done. The comment doesn't add anything to the issue, so please refrain from adding things like this in the future, as it only serves to irritate and antagonise.

Since this has been tagged as a high priority issue, is there a published timeline somewhere of how long it will take before a release is published after the fix has been merged?

The fix is undergoing testing and will be made by early next week.

doherty100 commented 10 months ago

The fix is undergoing testing and will be made by early next week.

@pauby thanks for the update on timing, I will reach out to my customers who are impacted to set expectations.

pauby commented 10 months ago

This has now been released and is available in the PowerShell Gallery.

doherty100 commented 10 months ago

Confirmed cChoco v2.6.0 resolves the issue, thanks @pauby and team for the lightning fast turn around!