`checkout`: cwd needs upper case drive letter on Windows
See original GitHub issueBug Report
Description
The VS Code extension creates child processes to run the CLI. We use the root directory of each DVC project as the cwd for these processes. When running checkout from one of these processes we run into unexpected errors on Windows. E.g
dvc checkout foo.txt
ERROR: Did you mean `git checkout foo.txt`?: 'foo.txt' does not exist as an output or a stage name in 'dvc.yaml': 'dvc.yaml' does not exist
From debugging it appears that the error is caused by passing the CLI a lower case drive letter in the cwd. @efiop has told me that DVC uses os.getcwd()
which returns an upper case drive letter.
As reported by a user on Discord, who provided an example repository: https://github.com/HaddocktheHorrible/dvc-test
Reproduce
- Use the VS Code extension on a Windows machine.
- Have changes in the workspace.
- Attempt to
checkout
a file from the SCM view. - Error will be thrown.
Expected
DVC can handle case differences in the cwd path on Windows.
Environment information
Output of dvc doctor
:
$ dvc doctor
DVC version: 2.11.0 (exe)
---------------------------------
Platform: Python 3.8.10 on Windows-10-10.0.19043-SP0
Supports:
azure (adlfs = 2022.4.0, knack = 0.9.0, azure-identity = 1.10.0),
gdrive (pydrive2 = 1.10.1),
gs (gcsfs = 2022.5.0),
hdfs (fsspec = 2022.5.0, pyarrow = 8.0.0),
webhdfs (fsspec = 2022.5.0),
http (aiohttp = 3.8.1, aiohttp-retry = 2.4.6),
https (aiohttp = 3.8.1, aiohttp-retry = 2.4.6),
s3 (s3fs = 2022.5.0, boto3 = 1.21.21),
ssh (sshfs = 2022.6.0),
oss (ossfs = 2021.8.0),
webdav (webdav4 = 0.9.7),
webdavs (webdav4 = 0.9.7)
Cache types: hardlink
Cache directory: NTFS on C:\
Caches: local
Remotes: local
Workspace directory: NTFS on C:\
Repo: dvc, git
Additional Information (if any):
I will provide more information as I get it. Getting access to a Windows box shortly (debugging up to this point was done with @sroy3 on her Windows machine).
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:8 (7 by maintainers)
Top GitHub Comments
Windows paths are supposed to be case-insensitive (including drive letters), we are probably just missing an
os.path.normcase()
call somewhere before we do path (string) comparisonsNeed to double check if windows drives are really case-insensitive. Just in case there is a more complex problem here (or even intended behavior).