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

StopOnPackageFailure not working #464

Closed
boussaffawalid opened this issue Jan 19, 2021 · 3 comments
Closed

StopOnPackageFailure not working #464

boussaffawalid opened this issue Jan 19, 2021 · 3 comments
Labels
Bug Issues where something has happened which was not expected or intended Duplicate Issue Issues that are duplicates of other issues

Comments

@boussaffawalid
Copy link

What You Are Seeing?

using this demo file:

# demo.ps1
choco install -y non_existing_package
choco install -y 7zip

When running the command:

Boxstarter demo.ps1 -StopOnPackageFailure

It fail to install non_existing_package but it continue with installing 7zip

What Is Expected?

Boxstarter should stop after failing to install non_existing_package

Output Log

Full Log Output

=====
Boxstarter: Installing package dev.ps1
Boxstarter Version 2.13.0
(c) 2018 Chocolatey Software, Inc, 2012 - 2018 Matt Wrock. https://boxstarter.org

Please type CTRL+C or close this window to exit Boxstarter if you do not want to risk a reboot during this Boxstarter install.

Boxstarter may need to reboot your system.
Please provide your password so that Boxstarter may automatically log you on.
Your password will be securely stored and encrypted.
Autologon Password: ********
Boxstarter: Successfully authenticated password.
NoPassword is set to False and RebootOk is set to True and the NoPassword parameter passed was False and StopOnPackageFailure is set to True
Boxstarter: Disabling Automatic Updates from Windows Update
Attempting to build package from 'tmp491A.tmp.nuspec'.
Successfully created package 'C:\ProgramData\Boxstarter\BuildPackages\tmp491A.tmp.1.0.0.nupkg'
Boxstarter: Created a temporary package tmp491A.tmp from dev.ps1 in C:\ProgramData\Boxstarter\BuildPackages
++ Boxstarter starting Calling Chocolatey to install tmp491A.tmp. This may take several minutes to complete...
Installing the following packages:
tmp491A.tmp
By installing you accept licenses for the packages.
[NuGet] Installing 'tmp491A.tmp 1.0.0'.
[NuGet] Successfully installed 'tmp491A.tmp 1.0.0'.

tmp491A.tmp v1.0.0 (forced)
tmp491a.tmp package files install completed. Performing other installation steps.

  • Boxstarter starting Calling Chocolatey to install non_existing_package. This may take several minutes to complete...
  • Boxstarter starting Calling Chocolatey to install non_existing_package. This may take several minutes to complete...
    Installing the following packages:
    non_existing_package
    By installing you accept licenses for the packages.
    non_existing_package not installed. The package was not found with the source(s) listed.
    If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not.
    Version: ""
    Source(s): "C:\ProgramData\Boxstarter\BuildPackages;https://chocolatey.org/api/v2"

Chocolatey installed 0/1 packages. 1 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures

  • non_existing_package - non_existing_package not installed. The package was not found with the source(s) listed.
    If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not.
    Version: ""
    Source(s): "C:\ProgramData\Boxstarter\BuildPackages;https://chocolatey.org/api/v2"
    Chocolatey reported an unsuccessful exit code of 1. See C:\Users\walid\AppData\Local\Boxstarter\boxstarter.log for details.
    Boxstarter: Error from Chocolatey:

Message : Chocolatey reported an unsuccessful exit code of 1. See C:\Users\walid\AppData\Local\Boxstarter\boxstarter.log for details.
Data : {}
InnerException :
TargetSite :
StackTrace :
HelpLink :
Source :
HResult : -2146233087

Boxstarter: Error from Chocolatey:

Message : Chocolatey reported an unsuccessful exit code of 1. See C:\Users\walid\AppData\Local\Boxstarter\boxstarter.log for details.
Data : {}
InnerException :
TargetSite :
StackTrace :
HelpLink :
Source :
HResult : -2146233087

  • Boxstarter finished Calling Chocolatey to install non_existing_package. This may take several minutes to complete... 00:00:01.4879139
  • Boxstarter finished Calling Chocolatey to install non_existing_package. This may take several minutes to complete... 00:00:01.4879139
  • Boxstarter starting Calling Chocolatey to install 7zip. This may take several minutes to complete...
  • Boxstarter starting Calling Chocolatey to install 7zip. This may take several minutes to complete...
    Installing the following packages:
    7zip
    By installing you accept licenses for the packages.
    7zip v19.0 already installed.
    Use --force to reinstall, specify a version to install, or try upgrade.

Chocolatey installed 0/1 packages. 0 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Warnings:

  • 7zip - 7zip v19.0 already installed.
    Use --force to reinstall, specify a version to install, or try upgrade.
  • Boxstarter finished Calling Chocolatey to install 7zip. This may take several minutes to complete... 00:00:00.3755413
  • Boxstarter finished Calling Chocolatey to install 7zip. This may take several minutes to complete... 00:00:00.3755413
    Only an exit code of non-zero will fail the package by default. Set
    --failonstderr if you want error messages to also fail a script. See
    choco -h for details.
    The install of tmp491a.tmp was successful.
    Software install location not explicitly set, could be in package or
    default install location if installer.

Chocolatey installed 1/1 packages. 0 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
++ Boxstarter finished Calling Chocolatey to install tmp491A.tmp. This may take several minutes to complete... 00:00:08.6981152
True
Boxstarter: Restore Automatic Updates from Windows Update

@boussaffawalid boussaffawalid added the Bug Issues where something has happened which was not expected or intended label Jan 19, 2021
@flcdrg
Copy link
Member

flcdrg commented Jan 19, 2021

What happens if you put $ErrorActionPreference = 'Stop' at the top of the script?

@boussaffawalid
Copy link
Author

same behavior even I set $ErrorActionPreference = 'Stop'


I tried to set $Boxstarter.StopOnPackageFailure=$true in my demo.ps1 script and it is working as expected.

However -StopOnPackageFailure is not working when it is set from command line.

@flcdrg flcdrg added the Duplicate Issue Issues that are duplicates of other issues label Jan 19, 2021
@flcdrg
Copy link
Member

flcdrg commented Jan 19, 2021

Looks like this probably a duplicate of #451 (which has a pending PR)

@flcdrg flcdrg closed this as completed Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues where something has happened which was not expected or intended Duplicate Issue Issues that are duplicates of other issues
Projects
None yet
Development

No branches or pull requests

2 participants