boxstarter
boxstarter copied to clipboard
Boxstarter should report how many packages failed to install
What You Are Seeing?
Invoke-ChocolateyBoxstarter doesn't provide any information if something failed along the way.
What is Expected?
(in case of 'no-reboots-required') either $lastexitcode
or a try{ .. } catch { ...}
should be sufficient to check if something went wrong.
How Did You Get This To Happen? (Steps to Reproduce)
using Boxstarter.bat
C:\myboxstarter\Boxstarter.bat pkg_does_not_exist
echo %errorlevel%
I'd suggest something like
if($chocoErrors -gt 0){
$lastexitcode = $chocoErrors
throw "got $chocoErrors Chocolatey errors"
}
here, right after the foreach($packageName in $packageNames){ ... }
If you used the throw
statement it would stop the rest of Boxstarter. What we need to decide is if not being able to install packages is something that is a critical error or not. It may also come into the realms of #296 ?
What might be nice is if we have somewhere we can log issues / warnings / errors that the end user should know about and then, when everything is done, display them to the user? Something like a Add-BoxstarterIssue
and then a Write-BoxstarterIssue
(I'm just thinking out loud just now).
I was also thinking about #296, in contrast to the (initial) suggested change there, this would actually try to install all packages, before setting $lastexitcode
to the number of failed choco install
s.
Rather then the number of failed installs (does it matter how many?) you could just exit 1 or 0?
I'm not against the idea. I think that:
-
Maybe we should turn it into a copy larger feature (such as recording the errors like I suggested above);
-
Would be interested in seeing the detail on how it's done;
I actually don't care how many installs failed, the thing is that, with a current version of Boxstarter, it is hard to get some useful return/exit code that tells you if something went wrong or not.
I do like your suggestion with the Add-BoxstarterIssue
, followed by a final Get-BoxstarterIssues | % { Write-BoxstarterIssue $_ }
, but also would need to put something like
if ((Get-BoxstarterIssues).Count -gt 0) {
exit 1
}
somewhere at the end of the default Boxstarter procedure.
(it should not matter, if you call Invoke-ChocolateyBoxstarter pkg1,pkg2
or Boxstarter.bat pkg1,pkg2
)
Just revisited this. Note: when this is being implemented, take sure to note this:
If you used the throw statement it would stop the rest of Boxstarter.
meaning: reporting of the install error and setting of the return code must happen last, after Boxstarter cleanup-phase (UAC, Win-Update Settings etc. need to be restored!!)
@mwallner is this not fixed with PR #296 / #402 ?
Short answer: no, this issue is something different as we're aiming to provide some feedback on which packages were installed successfully and which failed - after the Boxstarter procedure finished. (without the early-stopping bits)