-
Notifications
You must be signed in to change notification settings - Fork 342
Chocolatey-Install should return non-zero exit code if chocolateyInstall.ps1 fails #568
Comments
Agreed. |
I wonder if the chocolateyInstall.ps1 is swallowing the error... |
I've had the same problem. The exception thrown from my package's chocolateyInstall.ps1 is not bubbling up - it is being caught in Chocolatey-Nuget.ps1 and not re-thrown (~line 93). There appears to be an attempt to fail the package by setting $chocolateyErrored to $true, but this variable is false again by the time it is evaluated in chocolatey.ps1. Re-throwing the exception appears to resolve the issue. |
@warnergodfrey @bmedlin I believe this was just fixed by @mwrock in a recent PR. |
my PR addresses the exit code but does not rethrow. Honestly I personally prefer actually rethrowing the actual exception. For something like Boxstarter which calls the chocolatey powershell functiuons directly, I can better inspect the exception and provide better logging. I realize that will no longer be possible with choco.exe. Another PR I considered was adding more detail to the exceptions logged. Currently chocolotey just captures the error message which is sometimes not very helpful. Doing something like logging:
would capture any stacktrace and inner exceptions and even script level stack trace on later OSs. I'm probably gonna hold off on contributing that until the new chocolatey comes out but this is my 2 cents. :) Also, chocolatey simply returns an exit code of 1 and it would be better to at least return the original exit code. My PR was just an attempt to "fix" what appeared to be the current intent of the code. On the boxstarter side I can always just examine the |
@mwrock where would you put that bit of code? |
@mwrock nevermind, found a good spot. :) |
* stable: 0.9.8.32 (doc) updating changelog (GH-568) capture and return errors
If a package's install script fails and exits with a non-zero exit code then choco install still returns with a zero exit code. This behaviour is consistent in both v0.9.8.27 and v0.9.8.28-alpha2.
Run-ChocolateyPS1 throws an error if the chocolateyInstall.ps1 or chocolateyUninstall.ps1 fails, however the Chocolatey-NuGet.ps1 swallows the exception. The exception should bubble up and cause the choco command to fail.
The text was updated successfully, but these errors were encountered: