{"record":{"id":"e08f38acd56e9214","repo":"chocolatey/choco","slug":"stopping-further-execution-as-0-has-failed-1","errorCode":null,"errorMessage":"Stopping further execution as {0} has failed {1}.","messagePattern":"Stopping further execution as (.+?) has failed (.+?)\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs","lineNumber":595,"sourceCode":"            {\r\n                if (config.Features.ExitOnRebootDetected)\r\n                {\r\n                    Environment.ExitCode = ApplicationParameters.ExitCodes.ErrorInstallSuspend;\r\n                    this.Log().Warn(ChocolateyLoggers.Important, @\"Chocolatey has detected a pending reboot after installing/upgrading\r\npackage '{0}' - stopping further execution\".FormatWith(packageResult.Name));\r\n\r\n                    throw new ApplicationException(\"Reboot required before continuing. Reboot and run the same command again.\");\r\n                }\r\n            }\r\n\r\n            if (!packageResult.Success)\r\n            {\r\n                this.Log().Error(ChocolateyLoggers.Important, \"The {0} of {1} was NOT successful.\".FormatWith(commandName.ToStringSafe(), packageResult.Name));\r\n                HandleFailedOperation(config, packageResult, movePackageToFailureLocation: true, attemptRollback: true);\r\n\r\n                if (config.Features.StopOnFirstPackageFailure)\r\n                {\r\n                    throw new ApplicationException(\"Stopping further execution as {0} has failed {1}.\".FormatWith(packageResult.Name, commandName.ToStringSafe()));\r\n                }\r\n\r\n                return;\r\n            }\r\n\r\n            RemoveBackupIfExists(packageResult);\r\n\r\n            this.Log().Info(ChocolateyLoggers.Important, \" The {0} of {1} was successful.\".FormatWith(commandName.ToStringSafe(), packageResult.Name));\r\n\r\n            var installerDetected = Environment.GetEnvironmentVariable(EnvironmentVariables.Package.ChocolateyInstallerType);\r\n            if (!string.IsNullOrWhiteSpace(pkgInfo.DeploymentLocation))\r\n            {\r\n                this.Log().Info(ChocolateyLoggers.Important, \"  Deployed to '{0}'\".FormatWith(pkgInfo.DeploymentLocation.EscapeCurlyBraces()));\r\n            }\r\n            else if (!string.IsNullOrWhiteSpace(installerDetected))\r\n            {\r\n                this.Log().Info(ChocolateyLoggers.Important, @\"  Software installed as '{0}', install location is likely default.\".FormatWith(installerDetected));\r\n            }\r","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs#L577-L613","documentation":"Thrown as an ApplicationException during HandlePackageResult when a package install or upgrade fails (packageResult.Success is false) AND config.Features.StopOnFirstPackageFailure is enabled. The package has already been moved to the failure location and rolled back before the exception propagates, halting the entire batch.","triggerScenarios":"Inside HandlePackageResult, after HandleFailedOperation runs (moves package to failure location and attempts rollback), if config.Features.StopOnFirstPackageFailure is true and packageResult.Success is false, this exception is thrown immediately, preventing subsequent packages in the batch from being processed.","commonSituations":"Running 'choco upgrade all -y' or a multi-package install where one package fails. With stopOnFirstPackageFailure enabled, the first failure aborts the entire run. Without it, Chocolatey continues processing remaining packages and reports failures at the end.","solutions":["Investigate the specific package failure in the log (the error for that package is logged before this exception).","If you want remaining packages to install despite one failure, disable the feature: 'choco feature disable --name=stopOnFirstPackageFailure'.","Fix or update the failing package, then re-run the command.","Exclude the problematic package with --except or install packages individually to isolate the failure."],"exampleFix":"// before: feature stops batch on first failure\nchoco feature enable --name=stopOnFirstPackageFailure\nchoco upgrade all -y  # stops on first failing package\n\n// after: continue processing remaining packages\nchoco feature disable --name=stopOnFirstPackageFailure\nchoco upgrade all -y  # processes all, reports failures at end","handlingStrategy":"validation","validationCode":"// Validate the feature flag and known-good packages before batch operations\nif (config.Features.StopOnFirstPackageFailure)\n{\n    logger.Info(\"stopOnFirstPackageFailure is enabled — batch will abort on first failure.\");\n    // Consider pre-checking each package's availability\n    foreach (var name in config.PackageNames.Split(';'))\n    {\n        if (string.IsNullOrWhiteSpace(name)) continue;\n        // Verify package exists in source before committing\n    }\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    _packageService.Install(config);\n}\ncatch (ApplicationException ex) when (ex.Message.Contains(\"Stopping further execution\"))\n{\n    // The failing package name is in the message\n    // Other packages were NOT processed — re-run without the failing one\n    logger.Error($\"Batch stopped: {ex.Message}\");\n    logger.Info(\"Disable stopOnFirstPackageFailure or fix the failing package and retry.\");\n}","preventionTips":["Disable stopOnFirstPackageFailure for resilient batch installs where partial success is acceptable.","Pre-validate package availability in sources before batch operations.","Test new or updated packages individually before including them in batch upgrades.","Use --except to skip known-problematic packages in 'choco upgrade all'."],"tags":["install","upgrade","failure","stoponfirstpackagefailure","batch","chocolatey"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}