xcopy fails in AppVeyor, works at home: Invalid number of parameters

121 Views Asked by At

The command xcopy "$SITEPACKAGES\\google" "build\\lib\\google" /i /e /h fails with Invalid number of parameters on Windows on AppVeyor (Visual Studio 2019).

I’ve confirmed the correct syntax of the command in my Windows virtual machine on my computer where the command works as expected, and I’ve confirmed the correct setting of the $SITEPACKAGES variable and the escaped backslashes by echoing the same line: echo "$SITEPACKAGES\\google" "build\\lib\\google" /i /e /h produces C:\Python37-x64\Lib\site-packages\google build\lib\google /i /e /h, now with the quotes not showing anymore as expected.

The command is run from a shell schript as a normal command from appveyor.yml like so:

build_script:
    - cmd: "sh wxPython/build/Windows/build-all.sh"

I’ve also tried not to escape the backslashes, but with same result.

I'm lost. Any ideas?

3

There are 3 best solutions below

1
On

I believe there are some backslashes missing, as you can see from my attempts:

C:\Users\Gebruiker>xcopy C:\Python37-x64\Lib\site-packages\google build\lib\google /i /e /h
File not found - google
0 File(s) copied

C:\Users\Gebruiker>xcopy C:\Python37-x64\Lib\site-packages\google\ build\lib\google\ /i /e /h
Invalid path
0 File(s) copied

Anyway, I'd advise to make sure you always have double quotes around your paths, you never know when a space might arrive in a directory's name.

1
On

Still not sure yet what the problem is, but it has shown in another instance that there’s some real problem here. My other question shows a similar behaviour. It seems that options are being interpreted as file name input.

Meanwhile I've wanted to post a workaround that helped me, which is to copy through Python:

python -c "import shutil; shutil.copytree('$SITEPACKAGES\\google', 'build\\lib\\google')"

0
On

Found the cleanest solution: Don't mix Windows and Linux (WSL) environments in AppVeyor (or probably generally).

Either call a shell script using sh or bash and then copy folders the Unix way with cp -r $SITEPACKAGES/google build/lib/ with appveyor.yml:

  build_script: 
    - cmd: sh somecommand.sh

or do it the Windows way and call a Windows batch script directly and then use Windows’ copy commands xcopy "$SITEPACKAGES\\google" "build\\lib\\google" /i /e /h with appveyor.yml:

  build_script: 
    - somecommand.bat