{"record":{"id":"a5060811cd03cf66","repo":"chocolatey/choco","slug":"0-1-not-successful","errorCode":null,"errorMessage":"{0} {1} not successful.","messagePattern":"(.+?) (.+?) not successful\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs","lineNumber":1560,"sourceCode":"                HandleFailedOperation(config, packageResult, movePackageToFailureLocation: true, attemptRollback: true);\r\n            }\r\n\r\n            if (_rebootExitCodes.Contains(packageResult.ExitCode))\r\n            {\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 uninstalling\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                // throw an error so that NuGet Service doesn't attempt to continue with package removal\r\n                throw new ApplicationException(\"{0} {1} not successful.\".FormatWith(packageResult.Name, \"uninstall\"));\r\n            }\r\n        }\r\n\r\n        private void UninstallCleanup(ChocolateyConfiguration config, PackageResult packageResult)\r\n        {\r\n            if (config.Features.RemovePackageInformationOnUninstall)\r\n            {\r\n                _packageInfoService.Remove(packageResult.PackageMetadata);\r\n            }\r\n\r\n            EnsureBadPackagesPathIsClean(packageResult);\r\n            RemoveBackupIfExists(packageResult);\r\n            HandleExtensionPackages(config, packageResult);\r\n            HandleTemplatePackages(config, packageResult);\r\n            HandleHookPackages(config, packageResult);\r\n\r\n            if (config.Force)\r\n            {\r","sourceCodeStart":1542,"sourceCodeEnd":1578,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs#L1542-L1578","documentation":"Thrown as an ApplicationException during HandlePackageUninstallResult when packageResult.Success is false after an uninstall attempt. This explicitly stops the NuGet service from continuing with package removal — it is a hard failure that propagates up. The message formats the package name and 'uninstall' as the operation.","triggerScenarios":"Inside HandlePackageUninstallResult, after checking reboot exit codes, the code checks packageResult.Success. If false (the uninstaller reported failure, non-zero exit code, or an error occurred), this exception is thrown unconditionally — there is no feature flag to skip it, unlike the StopOnFirstPackageFailure flow.","commonSituations":"An uninstaller returns a non-zero exit code (not a reboot code), a chocolateyUninstall.ps1 script errors out, or files are locked preventing removal. The error message follows the pattern '{packageName} uninstall not successful.'","solutions":["Check the log output for the specific uninstaller error — the Error-level log before this exception explains what went wrong.","Use --force to bypass exit code checks: 'choco uninstall pkg -y --force'.","Close applications that may be locking the package files before uninstalling.","Manually remove leftover files from the package directory in the lib folder if the uninstaller partially completed."],"exampleFix":"// before: uninstall fails due to locked files or exit code\nchoco uninstall mypackage -y\n\n// after: force removal, or close locking processes first\nchoco uninstall mypackage -y --force\n// or manually clean up\nRemove-Item -Recurse -Force $env:ChocolateyInstall\\lib\\mypackage","handlingStrategy":"try-catch","validationCode":"// Before uninstall, verify the package is installed and not locked\nforeach (var name in config.PackageNames.Split(';'))\n{\n    var pkgDir = _fileSystem.CombinePaths(ApplicationParameters.PackagesLocation, name);\n    if (!_fileSystem.DirectoryExists(pkgDir))\n    {\n        throw new InvalidOperationException($\"Package '{name}' is not installed locally.\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    _packageService.Uninstall(config);\n}\ncatch (ApplicationException ex) when (ex.Message.Contains(\"not successful\"))\n{\n    // The specific package and 'uninstall' are in the message\n    logger.Error($\"Uninstall failed: {ex.Message}\");\n    // Optionally retry with --force or clean up manually\n    logger.Info(\"Try: choco uninstall <pkg> -y --force\");\n}","preventionTips":["Close all applications that may be locking package files before uninstalling.","Use --force to bypass exit code validation when the uninstaller leaves non-critical artifacts.","Check the log output for the specific uninstaller error before this exception.","Manually remove the package directory from the lib folder if the uninstaller partially completed."],"tags":["uninstall","failure","exit-code","chocolatey"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}