Open MauricioCode opened 3 years ago
Hmmm.... that's interesting.
At the top of your block of code, do you have $ErrorActionPreference
set to Stop
? My guess is that you are missing that.
Without any logs here and without the full packaging script it is hard to know.
@ferventcoder : Attached a proof of concept NUPKG and the full LOG. PACKAGE.2020.09.01.nupkg.zip choco.log
Yes that is strange. I believe this behavior should be fixed for sure with Get-ChocolateyWebFile. I'll mark this up on the backlog for addressing the issue.
However, I did also want to address your use case scenario as I find it to be an anti-pattern with how we want folks to be packaging - downloads should only be a last resort due to things like publicly available packages that don't have distribution rights (like much of what you find on the community repository). If you have the files inside the package, there is no reason to go out to the internet. If you are following packaging standards and updating that file as you version (which is also correct behavior), then there should never be a reason to reach out to the internet to download the file you already downloaded inside the package.
What You Are Seeing?
When helper Get-ChocolateyWebFile encounters an error like 404 it dooms the script to fail at the end, even if the error was properly handled by the script.
What is Expected?
The function should issue a terminating error like every other helper, and the install / uninstall script should succeed if the error was correctly handled and the script allowed to reach the end.
How Did You Get This To Happen? (Steps to Reproduce)
Suppose this code:
This causes the script to proceed and the remaining code gets executed, but at the end the script will always fail with exit code 404, no matter what!
This is true even if:
Output Log
The install of PACKAGE was NOT successful. Error while running 'C:\ProgramData\chocolatey\lib\PACKAGE\tools\ChocolateyInstall.ps1'. See log for details. Moving 'C:\ProgramData\chocolatey\lib\PACKAGE' to 'C:\ProgramData\chocolatey\lib-bad\PACKAGE' Chocolatey installed 0/1 packages. 1 packages failed. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). Failures - PACKAGE (exited 404) - Error while running 'C:\ProgramData\chocolatey\lib\PACKAGE\tools\ChocolateyInstall.ps1'. See log for details. Sending message 'PostRunMessage' out if there are subscribers... Exiting with 404
~~~sh PLACE LOG CONTENT HERE - WE NEED _ALL_ DETAILED OUTPUT BASED ON THE ABOVE TO BE ABLE TO PROVIDE SUPPORT (YOU WILL FIND THAT IN THE $env:ChocolateyInstall\logs\chocolatey.log between the `=====`) ~~~