Skip to content

Commit

Permalink
dvc: do not set cache dir if not a dvc repo (iterative#3329)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Feb 14, 2020
1 parent 6932cf6 commit 77f24af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dvc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def load(self, validate=True):
self.update(conf)

# Add resolved default cache.dir
if not self["cache"].get("dir"):
if not self["cache"].get("dir") and self.dvc_dir:
self["cache"]["dir"] = os.path.join(self.dvc_dir, "cache")

def load_one(self, level):
Expand Down
7 changes: 6 additions & 1 deletion tests/func/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import configobj

from dvc.main import main
from dvc.config import ConfigError
from dvc.config import Config, ConfigError
from tests.basic_env import TestDvc


Expand Down Expand Up @@ -101,3 +101,8 @@ def test_merging_two_levels(dvc):
"url": "ssh://example.com",
"password": "1",
}


def test_config_loads_without_error_for_non_dvc_repo(tmp_dir):
# regression testing for https://github.com/iterative/dvc/issues/3328
Config(validate=True)

0 comments on commit 77f24af

Please sign in to comment.