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

$output -match 'fail' regex too generic #1

Closed
dbaileyut opened this issue Jun 15, 2021 · 6 comments
Closed

$output -match 'fail' regex too generic #1

dbaileyut opened this issue Jun 15, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@dbaileyut
Copy link

Hi,

I'm having problems with Foil and ChocolateyGet.

$failures = ($output -match 'fail')

This seems too generic of a regex.

E.g. Installing 'office365business' via DSC and ChocolateyGet, I got:

             [[PackageManagement]office365business] Installing the following

packages:
Office365Business
By installing you accept licenses for the packages.

Office365Business v13901.20336 [Approved]
office365business package files install completed. Performing other installation steps.
No custom configuration specified. Generating one...
No Product ID specified, using default: O365BusinessRetail
No excluded apps specified, installing all
No Language ID specified, using default: MatchOS
No updates value specified, using default: TRUE
No updates value specified, using default: TRUE
C:\windows\TEMP\chocolatey\Office365Business
Add
Updates
Display
Logging
RemoveMSI
Downloading Office365DeploymentTool
from
'https://download.microsoft.com/download/2/7/A/27AF1BE6-DD20-4CB4-B154-EBAB8A7D4A7E/officedeploymenttool_13901-20336.ex
e'

Download of officedeploymenttool_13901-20336.exe (3.35 MB) completed.
Hashes match.
Installing Office365DeploymentTool...
Office365DeploymentTool has been installed.
Installing Office365BusinessInstaller...
Office365BusinessInstaller has been installed.
Installing Office365Business...
Office365Business has been installed.
Cannot remove item C:\windows\TEMP\chocolatey\Office365Business: The process cannot access the file
'C:\windows\TEMP\chocolatey\Office365Business' because it is being used by another process.
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.
office365business may be able to be automatically uninstalled.
The install of office365business was successful.
Software installed to 'C:\Program Files\Microsoft Office'

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

Similarly, installing "sysinernals" to a custom location with ChocolateyGet results in a warning that has the word "fail" because it tries to referesh the environment variables.

@ethanbergstrom
Copy link
Owner

ethanbergstrom commented Jun 16, 2021

Hey @dbaileyut

Always happy to see a fellow DSC+ChocolateyGet user!

I think this goes back to PowerShell/Crescendo#63, where Cresendo doesn't have great any error handling, so I used something (very) simple to fill the gap.

I'll try to do some research as to what actual 'failure' output from Chocolatey looks like and write some better regex for it.

In the meantime, if it's an absolute blocker and you have an immediate need, I might suggest downgrading ChocolateyGet to v2.1.1, which doesn't use Foil and still uses exit code logic for determining failures, but should be functionally equivalent and still fixes an urgent issue (in a different way) introduced by a Chocolatey.org repository change described here: jianyunt/ChocolateyGet#24 (comment)

@dbaileyut
Copy link
Author

Thanks!

Yeah, I gave a thumbs up to PowerShell/Crescendo#63 before I submitted this issue because I figured that was the case :)

@ethanbergstrom
Copy link
Owner

Would you be able to provide a command example for sysinternals that yielded the "fail" output? I actually happen to use sysinternals with a custom install directory argument in my tests, and am not seeing the same behavior.

I did find a very helpful example of "uniquely error-like" text in chocolatey-community/chocolatey-packages#1608 reported to the Chocolatey core package maintainers repo, so I can use googlechrome v87.0.4280.141 to test for what valid error text looks like.

@ethanbergstrom
Copy link
Owner

ethanbergstrom commented Jun 16, 2021

Here's the new regex, I think it should work pretty well:

$failures = ($output -match 'Chocolatey installed \d+\/\d+ packages. \d+ packages failed\.')

Version 0.0.4 is out on PowerShell Gallery, and I think that should fix your issue. Can you try upgrading Foil to see if that fixes your issue? I wasn't able to reproduce with sysinternals, and Office 365 takes so long to install on my slower internet, I got impatient and gave up :)

@dbaileyut
Copy link
Author

Awesome! I'll try it out in just a bit and report back on the sysinternals warning too.

@dbaileyut
Copy link
Author

dbaileyut commented Jun 17, 2021

Huh, I'm not able to reproduce either the Office or Sysinternals issue now. I my best guess is I might have been using the built-in PackageMangement resource instead of PSDscResources/PackageManagement 1.4.7

The warning I was getting came from
Set-EnvironmentVariable.ps1

Called by (semi stack trace here):
Install-ChocolateyPath.ps1
Sysinternals/chocolateyInstall.ps1

I think the updated regex will be much more reliable either way.

Thanks again! And, kudos on a great name for the module.

@ethanbergstrom ethanbergstrom added the bug Something isn't working label Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants