$ErrorActionPreference seems to reset to 'Stop'

xeijin's Avatar

xeijin

09 Aug, 2018 09:47 PM

Hello,

I am using a powershell script to install a number of components using a utility called scoop (www.scoop.sh) itself comprised of powershell scripts.

The install script runs fine on my local Windows 10 machine in powershell, but once I tried the same script in AppVeyor the build was failing with what look like terminating errors (even though these aren't terminating on my local machine).

So I set $ErrorActionPreference = 'Continue' (which I didn't have to do on my local machine) to try and force it to continue - this worked, to an extent, but now with particular apps (e.g. installing WinPython) the $ErrorActionPreference seems to reset and I get the following error which terminates the build (pip install superset was the originating command):

Adding superset to Pipfile's [packages]...
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Pipfile.lock (ca72e7) out of date, updating to (34bbda)...

Note that the last line "Pipfile.lock..." is not even an error - simply a regular console message?

This particularly seems to be the case when the installer calls another executable e.g. pip but also eclipsec.exe when updating plugins for an application called KNIME Analytics Platform.

Anyone know what's up here, or even why AppVeyor might not be behaving like my local PowerShell?

  1. 1 Posted by xeijin on 09 Aug, 2018 09:50 PM

    xeijin's Avatar
  2. 2 Posted by xeijin on 11 Aug, 2018 11:31 AM

    xeijin's Avatar

    Further investigation: If I RDP into the VM during the build, then run the script from a PowerShell console, the issue does not occur -- does anyone know what AppVeyor is doing differently when it executes my script via the web interface?

  3. Support Staff 3 Posted by Owen McDonnell on 12 Aug, 2018 03:17 PM

    Owen McDonnell's Avatar

    Sorry for the delay, I forked your repo and tried running some builds to investigate but did not reach a conclusion yet.
    But upon picking up the matter today I see that several of your recent builds are succeeding.
    Did you find a solution to this problem?

  4. 4 Posted by xeijin on 18 Aug, 2018 09:22 PM

    xeijin's Avatar

    I made a pull request in the upstream app to fix the 'issue' there (a script was setting $errorActionPreference, but not setting it back), but the script in question was designed to be called, so its variable scope should only be active as long as the script is in use, and discarded once it finishes.

    In other words, the problem remains that I still cannot figure out why AppVeyor is behaving differently to a local powershell prompt in this instance.

  5. Support Staff 5 Posted by Owen McDonnell on 21 Aug, 2018 01:17 PM

    Owen McDonnell's Avatar

    To which 'upstream app' are you referring? Superset, knime ?
    I believe you are correct that the scope of $errorActionPreference variable, if set in a called script should be 'reset' after the script returns.
    So, ignoring anything to do with resetting that variable, can you point me to a build that worked on your local machine but failed in AppVeyor.
    Also, are you relying on any environment variables in your local build?

  6. 6 Posted by xeijin on 25 Aug, 2018 12:27 AM

    xeijin's Avatar

    The 'app' is actually scoop (www.scoop.sh) a download/extract/install framework which I'm using to install a number of different programs via command line.

    It uses json manifests & powershell scripts to provide an apt-get like install interface (a bit like chooclatey, but narrower focus). It uses GitHub repos as the storage area for the manifests.

    In this instance it was installing knime that caused the issue -- I run a specially modified version of the manifest (see my repo 'propositum-bucket'), that also installs plugins for knime after the main installation. It seems certain actions of the installer are being interpreted as an 'error' by AppVeyor but are not by a local prompt.

    As for environment variables, I was using a few in the script (which I later realised were causing me issues) I've now fixed this (or at least, I'm setting them in the recommended way from the build script) - see the file 'propositum-windows.ps1'.

    Thanks.

  7. Support Staff 7 Posted by Owen McDonnell on 28 Aug, 2018 05:15 PM

    Owen McDonnell's Avatar

    I'm not too clear about whether or not you've sorted this problem out or not.

    You mentioned that install of 'knime' was causing issue, but in the original build it seemed that install of 'superset-p' was causing the issue.

  8. 8 Posted by xeijin on 12 Sep, 2018 08:38 PM

    xeijin's Avatar

    I've solved the problem by submitting a pull request the app I'm using (scoop) to reset $ErrorActionPreference value inside a script it runs each time it installs an application.

    However, I shouldn't need to do this, as the value of the variable should be reset each time a script is called - but for some reaosn AppVeyor persists this.

  9. Support Staff 9 Posted by Owen McDonnell on 19 Sep, 2018 07:09 AM

    Owen McDonnell's Avatar

    I am still a little confused.It seems that in the first post you said that the problem was that "$ErrorActionPreference seems to reset and I get the following error...", but in later replies you are saying "the value of the variable should be reset each time a script is called".

    Anyway, this preference variable is not honored in called scripts. You could set it globally with $global:ErrorActionPreference = "Continue" if you want it to be the same in called scripts.
    Since AppVeyor runs a custom powershell host, it doesn't necessarily work exactly like a local powershell session might.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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

Recent Discussions

23 Oct, 2018 08:45 PM
23 Oct, 2018 07:48 PM
23 Oct, 2018 06:50 PM
23 Oct, 2018 06:06 PM
23 Oct, 2018 05:51 PM