Calling external executable causes NativeCommandError despite no apparent error

Bryan W. Weber's Avatar

Bryan W. Weber

16 Oct, 2016 01:29 AM

Hello! I am trying to upload a conda package to Anaconda Cloud using the anaconda upload command. On Appveyor, this causes a NativeCommandError to be thrown, despite the fact that the upload apparently succeeds. This causes the build to fail unnecessarily. The specific job is here: and the appveyor.yml file is here:

I tried to reproduce this error locally on a Windows 10 machine, but the upload succeeded without any error being thrown. How can I ignore or override this error to ensure the build status is successful?

  1. Support Staff 1 Posted by Feodor Fitsner on 16 Oct, 2016 04:11 AM

    Feodor Fitsner's Avatar

    Hi Bryan,

    There is NativeCommandError because this command is executed as PowerShell and it writes to StdErr. Anything written to StdErr is treated by PowerShell as exceptions. You should run it in CMD mode.

  2. 2 Posted by Bryan W. Weber on 16 Oct, 2016 04:14 PM

    Bryan W. Weber's Avatar

    Hi Feodor,

    Thanks for the quick reply. I have that command in PS mode because I had a lot of trouble writing the if statement in batch syntax. I thought that using cmd /c would run the anaconda upload in CMD mode. In addition, running the same command locally (without using cmd /c) does not throw the same error. Finally, I had tried redirecting STDERR to STDOUT but that didn't seem to help either.

    Any advice how to write that if statement in batch syntax, if that's the only way to avoid the NativeCommandError? You can see my previous attempt here:
    I had trouble with a syntax error and I thought it might be because the multi-line CMD commands are not allowed.


  3. Support Staff 3 Posted by Feodor Fitsner on 16 Oct, 2016 06:03 PM

    Feodor Fitsner's Avatar

    I'd change it to:

      - cmd: set PATH=%PYTHON_LOC%;%PYTHON_LOC%\Scripts;%PATH%
      - ps: if($env:APPVEYOR_REPO_BRANCH -eq "master" -and !$env:APPVEYOR_PULL_REQUEST_NUMBER) { $env:conda_upload = 'true' }
      - cmd: IF "%conda_upload%"=="true" anaconda -t %ANACONDA_KEY% upload --force -l dev "%PYTHON_LOC%\conda-bld\win-%BUILD_ARCH%\cantera*.tar.bz2"
  4. 4 Posted by Bryan W. Weber on 16 Oct, 2016 06:42 PM

    Bryan W. Weber's Avatar

    Thanks Feodor, that seems to have worked! Much appreciated.


  5. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:09 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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