tag:help.appveyor.com,2012-11-13:/discussions/problems/5413-calling-external-executable-causes-nativecommanderror-despite-no-apparent-errorAppVeyor: Discussion 2018-10-19T08:18:03Ztag:help.appveyor.com,2012-11-13:Comment/410000642016-10-16T01:29:09Z2016-10-16T16:16:08ZCalling external executable causes NativeCommandError despite no apparent error<div><p>Hello! I am trying to upload a conda package to Anaconda Cloud
using the <code>anaconda upload</code> command. On Appveyor, this
causes a <code>NativeCommandError</code> to be thrown, despite the
fact that the upload apparently succeeds. This causes the build to
fail unnecessarily. The specific job is here: <a href="https://ci.appveyor.com/project/Cantera/conda-recipes/build/job/7dwcgn16bwsgv7ch">
https://ci.appveyor.com/project/Cantera/conda-recipes/build/job/7dw...</a>
and the appveyor.yml file is here: <a href="https://github.com/Cantera/conda-recipes/blob/15b83a5d7973e0c4b4260bed1c17d4e53cf97dc4/appveyor.yml">
https://github.com/Cantera/conda-recipes/blob/15b83a5d7973e0c4b4260...</a></p>
<p>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?</p></div>Bryan W. Webertag:help.appveyor.com,2012-11-13:Comment/410000642016-10-16T04:11:39Z2016-10-16T04:11:39ZCalling external executable causes NativeCommandError despite no apparent error<div><p>Hi Bryan,</p>
<p>There is <code>NativeCommandError</code> because <a href="https://github.com/Cantera/conda-recipes/blob/15b83a5d7973e0c4b4260bed1c17d4e53cf97dc4/appveyor.yml#L48">
this command</a> is executed as PowerShell and it writes to StdErr.
Anything written to StdErr is treated by PowerShell as exceptions.
You should run it in <code>CMD</code> mode.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/410000642016-10-16T16:14:10Z2016-10-16T16:16:08ZCalling external executable causes NativeCommandError despite no apparent error<div><p>Hi Feodor,</p>
<p>Thanks for the quick reply. I have that command in PS mode
because I had a lot of trouble writing the <code>if</code>
statement in batch syntax. I thought that using <code>cmd /c</code>
would run the <code>anaconda upload</code> in <code>CMD</code>
mode. In addition, running the same command locally (without using
<code>cmd /c</code>) does not throw the same error. Finally, I had
tried redirecting STDERR to STDOUT but that didn't seem to help
either.</p>
<p>Any advice how to write that <code>if</code> statement in batch
syntax, if that's the only way to avoid the
<code>NativeCommandError</code>? You can see my previous attempt
here: <a href="https://github.com/Cantera/conda-recipes/blob/259aaff50e883da46d24fd78d0c9b69f171f2805/appveyor.yml#L43">
https://github.com/Cantera/conda-recipes/blob/259aaff50e883da46d24f...</a><br>
I had trouble with a syntax error and I thought it might be because
the multi-line CMD commands are not allowed.</p>
<p>Thanks!<br>
Bryan</p></div>Bryan W. Webertag:help.appveyor.com,2012-11-13:Comment/410000642016-10-16T18:03:06Z2016-10-16T18:03:06ZCalling external executable causes NativeCommandError despite no apparent error<div><p>I'd change it to:</p>
<pre>
<code>deploy_script:
- 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"</code>
</pre></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/410000642016-10-16T18:42:50Z2016-10-16T18:42:50ZCalling external executable causes NativeCommandError despite no apparent error<div><p>Thanks Feodor, that seems to have worked! Much appreciated.</p>
<p>Bryan</p></div>Bryan W. Weber