diff --git a/dvc/config.py b/dvc/config.py index 0fd312aa14..d2d60d68d1 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -24,15 +24,7 @@ def __init__(self, msg): class NoRemoteError(ConfigError): - def __init__(self, command): - msg = ( - "no remote specified. Setup default remote with\n" - " dvc remote default \n" - "or use:\n" - " dvc {} -r \n".format(command) - ) - - super().__init__(msg) + pass def supported_cache_type(types): diff --git a/dvc/data_cloud.py b/dvc/data_cloud.py index fadd536bd0..9babe164a4 100644 --- a/dvc/data_cloud.py +++ b/dvc/data_cloud.py @@ -39,7 +39,26 @@ def get_remote(self, remote=None, command=""): if remote: return self._init_remote(remote) - raise NoRemoteError(command) + has_non_default_remote = bool( + self.repo.config.list_options( + Config.SECTION_REMOTE_REGEX, Config.SECTION_REMOTE_URL + ) + ) + + if has_non_default_remote: + error_msg = ( + "no remote specified. Setup default remote with\n" + " dvc remote default \n" + "or use:\n" + " dvc {} -r ".format(command) + ) + else: + error_msg = ( + "no remote specified. Create a default remote with\n" + " dvc remote add -d " + ) + + raise NoRemoteError(error_msg) def _init_remote(self, remote): return Remote(self.repo, name=remote)