Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only fail automation scripts (chocolateyInstall.ps1) if the script returns non-zero exit code #445

ferventcoder opened this issue Oct 2, 2015 · 1 comment


Copy link

commented Oct 2, 2015

@mjiderhamn wrote:

Am I correct that if anything is output on stderr during installation, the installation is considered to be a failure?

In my installation script, I'm using Start-Process to invoke regasm, which outputs some warnings to standard error. The exit code is 0 and I don't care about the warnings, however Chocolatey decides that the installation failed.
Is there a way to override this behaviour (apart form -RedirectStandardError on Start-Process)?

@ferventcoder response:

Anything coming in as stderr right now triggers the install as a failure.

We should discuss if that is something we should not check.

This is up for discussion. We decided to move forward on this, and leave a way to get back the former behavior. Since this was considered a bug / regression for the 0.9.9 series, the 0.9.10 series will take it as a breaking change.


This comment has been minimized.

Copy link
Member Author

commented Dec 23, 2015

Also adding a switch and feature flag to set this back. The default behavior should be not to fail.

@ferventcoder ferventcoder added 3 - Done and removed 2 - Working labels Dec 23, 2015
@ferventcoder ferventcoder self-assigned this Dec 23, 2015
ferventcoder added a commit to ferventcoder/choco that referenced this issue Dec 23, 2015
Add a new switch and feature flag called `failOnStandardError`, that
will allow the older behavior of non-terminating errors to fail a
package. Otherwise log the error to stderr and give a warning message
that only an exit code of 1 will fail a package without the switch.
ferventcoder added a commit that referenced this issue Dec 23, 2015
* stable:
  (maint) formatting
  (spec) Ensure MockLogger is setup first in test suite
  (specs) Allow for nupkgs to finish copying
  (specs) use deep copy for config
  (GH-516) Fix: Log.InitializeWith doesn't clear cached loggers
  (GH-445) Only fail scripts on non-zero exit code
  (GH-510) allow silentargs in template
ferventcoder added a commit to ferventcoder/choco that referenced this issue Jan 1, 2016
ferventcoder added a commit to ferventcoder/choco that referenced this issue Jan 1, 2016
When running PowerShell operations, use a built-in PowerShell host by
default, allowing fallback to the older method of running Posh
by calling an external process. By building against the oldest version
of System.Management.Automation that aligns with the oldest Windows
Operating Systems supported, we can guarantee this will work on every
version of Windows where Chocolatey is supported.

In case we do run into issues, attempt to resolve the PowerShell
assemblies starting from the newest version and falling down to the
older versions until one is resolved or no version is resolved. There
is a known assembly that will go through this process every time -
System.Management.Automation.resources, en-US. To see those assemblies
go through, one must ask for both debug and verbose output.

This reverts the changes for chocolateyGH-249 in 9936876 and the changes
from chocolateyGH-349 in 344268b so that both paths (system powershell
and choco's built-in PowerShell) run with similar output and because by
default in d523e7b (chocolateyGH-445) choco no longer fails on the
presence of stderr output.
ferventcoder added a commit that referenced this issue Jan 1, 2016
* stable:
  (doc) update Changelog
  (GH-8) Use Custom PowerShell Host
  (GH-8) Configuration for PowerShell Host
  (GH-8) Implement Custom PowerShell Host
  (GH-8) Add System.Management.Automation binary
  (GH-8) Convert to SecureString
  (GH-8) ReadKey Timeout
  (GH-8) Run commands with timeout
  (maint) add messages to package installers
  (GH-8) ReadLine Timeout
  (GH-445) Scenario docs update
  (GH-520) Fix: Debug/Verbose messages not logged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.