# Buggy code
def _valid_dirname(self, path):
    dirname, basename = os.path.split(os.path.normpath(path))
    dirs, _ = self.dvcignore(os.path.abspath(dirname), [basename], [])
    if dirs:
        return True
    return False


# Traceback (FileNotFoundError)
NT> dvc metrics show -T
ERROR: unexpected error - [Errno 2] No such file

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
NT> dvc metrics show -T -v
2020-05-18 08:19:19,707 DEBUG: Trying to spawn '['c:\\program files\\python36\\python.exe', 'C:\\Program Files\\Python36
\\Scripts\\dvc', 'daemon', '-q', 'updater']'
2020-05-18 08:19:19,778 DEBUG: Spawned '['c:\\program files\\python36\\python.exe', 'C:\\Program Files\\Python36\\Script
s\\dvc', 'daemon', '-q', 'updater']'
2020-05-18 08:19:19,794 DEBUG: PRAGMA user_version;
2020-05-18 08:19:19,794 DEBUG: fetched: [(3,)]
2020-05-18 08:19:19,794 DEBUG: CREATE TABLE IF NOT EXISTS state (inode INTEGER PRIMARY KEY, mtime TEXT NOT NULL, size TE
XT NOT NULL, md5 TEXT NOT NULL, timestamp TEXT NOT NULL)
2020-05-18 08:19:19,825 DEBUG: CREATE TABLE IF NOT EXISTS state_info (count INTEGER)
2020-05-18 08:19:19,825 DEBUG: CREATE TABLE IF NOT EXISTS link_state (path TEXT PRIMARY KEY, inode INTEGER NOT NULL, mti
me TEXT NOT NULL)
2020-05-18 08:19:19,825 DEBUG: INSERT OR IGNORE INTO state_info (count) SELECT 0 WHERE NOT EXISTS (SELECT * FROM state_i
nfo)
2020-05-18 08:19:19,825 DEBUG: PRAGMA user_version = 3;
2020-05-18 08:19:19,965 DEBUG: SELECT count from state_info WHERE rowid=?
2020-05-18 08:19:19,981 DEBUG: fetched: [(38,)]
2020-05-18 08:19:19,981 DEBUG: UPDATE state_info SET count = ? WHERE rowid = ?
2020-05-18 08:19:20,059 ERROR: unexpected error - [Errno 2] No such file
------------------------------------------------------------
Traceback (most recent call last):
File "c:\program files\python36\lib\site-packages\dvc\main.py", line 49, in main
ret = cmd.run()
File "c:\program files\python36\lib\site-packages\dvc\command\metrics.py", line 49, in run
recursive=self.args.recursive,
File "c:\program files\python36\lib\site-packages\dvc\repo\metrics\__init__.py", line 13, in show
return show(self.repo, *args, **kwargs)
File "c:\program files\python36\lib\site-packages\dvc\repo\__init__.py", line 30, in wrapper
ret = f(repo, *args, **kwargs)
File "c:\program files\python36\lib\site-packages\dvc\repo\metrics\show.py", line 99, in show
metrics = _collect_metrics(repo, targets, recursive)
File "c:\program files\python36\lib\site-packages\dvc\repo\metrics\show.py", line 18, in _collect_metrics
for stage in repo.stages:
File "c:\program files\python36\lib\site-packages\funcy\objects.py", line 28, in __get__
res = instance.__dict__[self.fget.__name__] = self.fget(instance)
File "c:\program files\python36\lib\site-packages\dvc\repo\__init__.py", line 424, in stages
return self._collect_stages()
File "c:\program files\python36\lib\site-packages\dvc\repo\__init__.py", line 432, in _collect_stages
for root, dirs, files in self.tree.walk(self.root_dir):
File "c:\program files\python36\lib\site-packages\dvc\ignore.py", line 137, in walk
for root, dirs, files in self.tree.walk(top, topdown):
File "c:\program files\python36\lib\site-packages\dvc\scm\git\tree.py", line 139, in walk
raise IOError(errno.ENOENT, "No such file")
FileNotFoundError: [Errno 2] No such file
------------------------------------------------------------

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!

# Fixed code
def _valid_dirname(self, path):
    path = os.path.abspath(path)
    if path == self.tree_root:
        return True
    dirname, basename = os.path.split(path)
    dirs, _ = self.dvcignore(dirname, [basename], [])
    if dirs:
        return True
    return False