Dvc: Basic command compatibility with Windows PowerShell

Created on 18 Jul 2019  路  6Comments  路  Source: iterative/dvc

DVC version: 0.41.3
OS: Windows 10
Installation: exe (Windows)

I was trying to input data which is on another folder than my dvc repository. Therefore I was following the User Guide External Dependencies.

When using the cp command in my pipeline an error occurred that the cp command was not found, which I found strange, because powershell has it and I frequently use it.

The error message looked like the error you get when you try to use cp under the Windows CMD which has a different command palette.

If DVC actually would use the PowerShell when executed in it one could improve cross-platform compatibility between Linux/Windows because of the shared basic shell-commands (cp, mv, mkdir)

feature request help wanted p3-nice-to-have

All 6 comments

We'll need to figure out a way to detect if we are running from cmd or powershell and use the appropriate one in Popen.

After some investigation I found out you can tell python to use the powershell for system calls by changing the environment variable ComSpec which is used by Python to determine what shell to use, according to the official python documentation (https://docs.python.org/3.7/library/subprocess.html#module-subprocess)

Should we just put it as a recommendation here https://dvc.org/doc/user-guide/running-dvc-on-windows ?

As I don't know yet, which side effects/disadvantages it could have changing the COMPSPEC I would atleast add a warning/info to that recommendation.

When I try to set ComSpec to powershell in my powershell environment it breaks the running of .bat files like gvim.bat. It also appears to be trying to pass a \c flag to whatever program is specified, leading me to believe that for powershell (and maybe other tools?) ComSpec is expected to have a reference to cmd.exe.

Maybe there's a good way to set the variable only for the dvc command. I have had some luck (so far at least) with the following:

Function ddvc() {
   $oldComSpec=$env:ComSpec
   try {
      $env:ComSpec="$(Get-Command pwsh | select -ExpandProperty Source) -NoProfile"
      dvc @args
   } finally {
      $env:ComSpec=$oldComSpec
   }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

tc-ying picture tc-ying  路  3Comments

shcheklein picture shcheklein  路  3Comments

ghost picture ghost  路  3Comments

ghost picture ghost  路  3Comments

dmpetrov picture dmpetrov  路  3Comments