dvc
dvc copied to clipboard
version: fails when .git/ dir is removed from DVC repo
DVC 0.87.0
$ dvc version
ERROR: unexpected error - /... is not a git repository
Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
~~Maybe let's also check also other independent commands like dvc list and dvc get.~~
@jorgeorpinel, I'm unable to reproduce this on a temporary directory. Can you provide more information?
P.S. I was able to reproduce when I deleted .git folder inside a dvc init repo and then run dvc version.
git init && dvc init
rm -rf .git
dvc version
But, that's a different issue.
Good catch @skshetry, I think that's what was happening, but I didn't realize until now.
So is it a bug? Or expected behavior? Maybe the specific case can be handled with a better message at least? Changed the title and labels here, but feel free to close.
@jorgeorpinel It is a bug, indeed.
Reopening, looks like it's broken again:
$ dvc init --no-scm
$ dvc config core.no_scm False
$ dvc version -v
2020-06-18 22:39:10,654 ERROR: unexpected error - expected str, bytes or os.PathLike object, not NoneType
------------------------------------------------------------
Traceback (most recent call last):
File "/home/saugat/repos/iterative/dvc/dvc/main.py", line 53, in main
ret = cmd.run()
File "/home/saugat/repos/iterative/dvc/dvc/command/version.py", line 40, in run
repo = Repo()
File "/home/saugat/repos/iterative/dvc/dvc/repo/__init__.py", line 129, in __init__
self._ignore()
File "/home/saugat/repos/iterative/dvc/dvc/repo/__init__.py", line 198, in _ignore
self.scm.ignore_list(flist)
File "/home/saugat/repos/iterative/dvc/dvc/scm/base.py", line 81, in ignore_list
return [self.ignore(path) for path in p_list]
File "/home/saugat/repos/iterative/dvc/dvc/scm/base.py", line 81, in <listcomp>
return [self.ignore(path) for path in p_list]
File "/home/saugat/repos/iterative/dvc/dvc/scm/git/__init__.py", line 187, in ignore
entry, gitignore = self._get_gitignore(path)
File "/home/saugat/repos/iterative/dvc/dvc/scm/git/__init__.py", line 171, in _get_gitignore
if not path_isin(gitignore, os.path.realpath(self.root_dir)):
File "/home/saugat/.pyenv/versions/3.6.6/lib/python3.6/posixpath.py", line 387, in realpath
filename = os.fspath(filename)
TypeError: expected str, bytes or os.PathLike object, not NoneType
------------------------------------------------------------
This still throws an error, but it seems helpful now:
$ dvc version
DVC version: 2.12.1.dev14+gbd93d85d4
---------------------------------
Platform: Python 3.10.2 on macOS-12.4-arm64-arm-64bit
Supports:
azure (adlfs = 2022.4.0, knack = 0.9.0, azure-identity = 1.7.1),
gdrive (pydrive2 = 1.10.1),
gs (gcsfs = 2022.5.0),
hdfs (fsspec = 2022.5.0, pyarrow = 7.0.0),
webhdfs (fsspec = 2022.5.0),
http (aiohttp = 3.8.1, aiohttp-retry = 2.4.5),
https (aiohttp = 3.8.1, aiohttp-retry = 2.4.5),
s3 (s3fs = 2022.5.0, boto3 = 1.21.21),
ssh (sshfs = 2022.6.0),
oss (ossfs = 2021.8.0),
webdav (webdav4 = 0.9.4),
webdavs (webdav4 = 0.9.4)
Repo: dvc, git (broken)
ERROR: /Users/dave/repo is not a git repository
@skshetry Can we close this one?