What is the difference between Powershell warnings and error preferences in production and debug mode?
Some of the commands I execute during test phase produce output as INFO and NOTICE. Powershell flags this as an error and raises an exception during production mode but when I run the same commands in debug mode there is no error. I think there may be some difference in the error preferences. Can someone help me diagnose this ?
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Feodor Fitsner on 10 Jun, 2020 07:27 PM
Could you drop a link to a build please?
2 Posted by kartikohri13 on 11 Jun, 2020 09:04 AM
Please see https://ci.appveyor.com/project/amCap1712/pljava/builds/33437118 .
At the end of the build, Powershell fails the build with an exception
raised due to debug output. This issue does not happen in debug builds.
Support Staff 3 Posted by Feodor Fitsner on 11 Jun, 2020 08:52 PM
It's how PowerShell custom host is working. Windows PowerShell treats all writes to StdErr as exceptions.
To workaround that issue I'd move everything starting from
ps:
to a separate.ps1
scripts and then call them fromappveyor.yml
as:...or if
psql
command line has some "quiet" switch suppressing those messages that could work too....or you can use this great function (we use it while building images) to run process with right redirection or with suppressing StdErr: https://github.com/appveyor/build-images/blob/master/scripts/Window... Usage examples: https://github.com/appveyor/build-images/search?q=Start-ProcessWith...
4 Posted by kartikohri13 on 12 Jun, 2020 03:06 AM
Thanks for the help. Could you explain why merely moving commands from
appveyor.yml to a .ps1 script can fixt his issue?
Support Staff 5 Posted by Feodor Fitsner on 12 Jun, 2020 05:05 AM
The whole point of that is redirecting StdErr to StdOut.
6 Posted by Chapman Flack on 16 Jul, 2020 04:16 AM
Can someone explain why adding
2>&1
after a command inps:
mode, which is covered in the PowerShell docs for the exact purpose, won't work on AppVeyor?7 Posted by Chapman Flack on 17 Jul, 2020 03:08 AM
I may have hit the mother lode of information on this PowerShell behavior, in these two GitHub issues: 3996 and 4002.
When I started a separate instance of PowerShell and ran the external command from that, the stuff that command wrote on stderr never showed up in the log at all, it was just gone. Adding the PowerShell syntax
2>&1
made it show up in the log, merged with the stdout data. But that was not all it did. (On a POSIX system, that is all that syntax does; it simply makes one file descriptor a dup of another.)Under PowerShell, the formerly "stderr" data getting merged into "stdout" still got modified by PowerShell (or .NET or whatever layer is doing that). Something tried to assemble a structured 'error record' out of the start of the stderr data and display it as an exception. It all got strangely reformatted, as apparently the convert-stderr-to-error-records code deals poorly with stderr data arriving in fragments of lines (as often seen from external programs that report progress).
Those two GitHub issues contain a trove of information on what's going on.
Support Staff 8 Posted by Feodor Fitsner on 17 Jul, 2020 04:58 PM
Right, something is definitely wrong there. Thanks for sharing your investigation.
Feodor Fitsner closed this discussion on 16 Sep, 2020 09:03 PM.