From 034802fe3a96a585b47ba734eb60aee9e59762f3 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 18 Dec 2019 23:02:25 +0100 Subject: [PATCH 1/2] fix 2788 --- dvc/command/version.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dvc/command/version.py b/dvc/command/version.py index 91fa69fbdf..7f88a046c3 100644 --- a/dvc/command/version.py +++ b/dvc/command/version.py @@ -44,11 +44,17 @@ def run(self): binary=binary, package=PKG, ) - + + is_repo = False + try: repo = Repo() root_directory = repo.root_dir + is_repo = True + except NotDvcRepoError: + root_directory = os.getcwd() + if is_repo: # cache_dir might not exist yet (e.g. after `dvc init`), and we # can't auto-create it, as it might cause issues if the user # later decides to enable shared cache mode with @@ -70,14 +76,14 @@ def run(self): info += ( "Filesystem type (cache directory): {fs_cache}\n" ).format(fs_cache=self.get_fs_type(repo.cache.local.cache_dir)) - except NotDvcRepoError: - root_directory = os.getcwd() + else: + info += ("Cache: link not available (run inside DVC repo)\n") if psutil: info += ("Filesystem type (workspace): {fs_root}").format( fs_root=self.get_fs_type(os.path.abspath(root_directory)) ) - + logger.info(info) return 0 From 59ad4c8e68d7135081a48d760bf855512b16cc25 Mon Sep 17 00:00:00 2001 From: Patrick Date: Thu, 19 Dec 2019 00:06:19 +0100 Subject: [PATCH 2/2] output consistent with doc --- dvc/command/version.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dvc/command/version.py b/dvc/command/version.py index 7f88a046c3..d03cf9d1ce 100644 --- a/dvc/command/version.py +++ b/dvc/command/version.py @@ -76,14 +76,12 @@ def run(self): info += ( "Filesystem type (cache directory): {fs_cache}\n" ).format(fs_cache=self.get_fs_type(repo.cache.local.cache_dir)) - else: - info += ("Cache: link not available (run inside DVC repo)\n") - + if psutil: info += ("Filesystem type (workspace): {fs_root}").format( fs_root=self.get_fs_type(os.path.abspath(root_directory)) ) - + logger.info(info) return 0