chocolatey / cChoco

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

cChocoInstaller - Files from a previous installation of Chocolatey were found #162

Closed mivica closed 2 years ago

mivica commented 2 years ago

I get the below error intermittently with the "c:\choco" folder containing only one folder called "bin" and no files at all, e.g. "c:\choco\bin". The workaround is to remove the "c:\choco" folder from the drive, and the next DSC run goes all green. Can someone shed any light on this?

[[cChocoInstaller]InstallChoco] Files from a previous installation of Chocolatey were found at 'c:\choco'.

pauby commented 2 years ago

Can you provide the code you are using to install Choco / Package that results in this?

pauby commented 2 years ago

Does this issue resolve it?

mivica commented 2 years ago

The short answer is no. But at least we know what the issue may be, https://github.com/chocolatey/cChoco/issues/151#issuecomment-775166994. Is this going to get fixed and released soon?

pauby commented 2 years ago

This was fixed here and released. Are you running the latest version?

mivica commented 2 years ago

Yes, we are running the latest version, 2.5.0.


From: Paul Broadwith @.> Sent: Wednesday, October 6, 2021 5:32:01 PM To: chocolatey/cChoco @.> Cc: mivica @.>; Author @.> Subject: Re: [chocolatey/cChoco] cChocoInstaller - Files from a previous installation of Chocolatey were found (#162)

This was fixed herehttps://github.com/chocolatey/cChoco/commit/fbb7835ab44e555a23256126074a59ac09a31777 and released.https://github.com/chocolatey/cChoco/releases/tag/v2.5.0 Are you running the latest version?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/chocolatey/cChoco/issues/162#issuecomment-936631914, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACE2FPMCQWGAZ7D4NOPD4UDUFR2YDANCNFSM5FLRIBTA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

pauby commented 2 years ago

Then you have a different issue.

You mention that you have a folder with bin in there? Can you run the normal Chocolatey install script (ie. without DSC), installing to c:\choco, while the c:\chcoo\bin folder exists?

mivica commented 2 years ago

The folder structure, including bin, is entirely created by cChoco install DSC, and still, it fails intermittently. I did not try to run it any other way than through DSC.

Did the file I shared helped in any way?

pauby commented 2 years ago

The folder structure isn't created by cChoco. It's created by the Chocolatey install script.

Can you run the install script, on it's own, as I requested above, to see if you get the same issues?

The file you shared didn't shed any more light on it.

mivica commented 2 years ago

Hi, the issue is that the actual download is failing with "(429) Too Many Requests.", see below. At the same time, the install directory has already been created here before the download was triggered. So the next time DSC runs and completes the download, Choco installer figures it is already installed due to the existing install folder and throws the error I raised initially.

Is there a need to explicitly create this folder, does the installer creates it? One way to fix this would be to move directory creation after the download was successful.

"This event indicates that a non-terminating error was thrown when DSCEngine was executing Set-TargetResource on cChocoInstaller DSC resource. FullyQualifiedErrorId is WebException. Error Message is Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (429) Too Many Requests."."

pauby commented 2 years ago

I'm not entirely sure what's going on in this. From my tests with just this code:

Configuration InstallChoco
{
    Import-DscResource -Module cChoco
    Node "localhost"
    {
        cChocoInstaller InstallChoco
        {
            InstallDir = "c:\choco"
        }
    }
}

$config = InstallChoco

Start-DscConfiguration -Path $config.psparentpath -Wait -Verbose -Force

Chocolatey is installed into c:\choco (as I'm not getting the error you get obviously). But, there is no bin directory created. The bin directory is used for shims that are created when packages are installed.

I also used this code from this example but I altered this line to read $ChocoInstallScriptUrl = 'https://chocolatey.org/install.ps11' (note the additional 1 on the end). This simulates the script not downloading (as the URL is incorrect). I get the following error:

VERBOSE: [5AF69F8C-D72B-4]:                            [[cChocoInstaller]InstallChoco] Downloading                      https://chocolatey.org/install.ps11 to C:\Windows\TEMP\532a435a-551e-4e0a-b996-1a544ad719d5\install.ps1
Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (404) Not Found."
              + CategoryInfo          : NotSpecified: (:) [], CimException                                                            
              + FullyQualifiedErrorId : WebException                                                                                  
              + PSComputerName        : localhost                             

When I look at the c:\choco folder after the failed install, I see this:

image

Note the c:\choco folder is created but no bin folder.

The issue you are having is not that cChoco creates the c:\choco folder. The issue you are having is that c:\choco\bin is being created and I'm not sure what that is. But as far as I can tell it's not cChoco.

cChoco runs the Chocolatey install script and it doesn't look for the install folder (ie. c:\choco), it looks for anything inside the install folder and fails the install if it's found. As you have the bin folder in there Chocolatey won't install (see the function Test-ChocolateyInstalled in the install script).

So while cChoco is creating the c:\choco folder (and I'm not entirely sure why) this doesn't appear to be your issue.

mivica commented 2 years ago

Hi Paul, thank you for your response and your time. Yes, you are correct; my initial assessment was incomplete. There is more than one download in this workflow, install.ps1 itself triggers at least one. They can all intermittently fail with HTTP 429 at different stages, which explains the bin folder. 429 error is documented on the Chocolatey page. It makes it an unreliable approach to our automation scenario, which is why we decided to move away from Chocolatey entirely. I am closing this issue now.

pauby commented 2 years ago

@mivica you can host the install script yourself and pass the location of that to cChoco?

The Chocolatey Community Repository is not recommended for organisational use. There are a lot of docs around that (that I can't link to as I'm on my phone and don't have them to hand).

mivica commented 2 years ago

You can, and I tried. But one can still get 429 from the additional downloads the script itself is executing.


From: Paul Broadwith @.> Sent: Sunday, October 17, 2021 7:57:14 PM To: chocolatey/cChoco @.> Cc: mivica @.>; Mention @.> Subject: Re: [chocolatey/cChoco] cChocoInstaller - Files from a previous installation of Chocolatey were found (#162)

@mivicahttps://github.com/mivica you can host the install script yourself and pass the location of that to cChoco?

The Chocolatey Community Repository is not recommended for organisational use. There are a lot of docs around that (that I can't link to as I'm on my phone and don't have them to hand).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/chocolatey/cChoco/issues/162#issuecomment-945176369, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACE2FPLECTNF7R6XQQR2NVDUHMMAVANCNFSM5FLRIBTA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.