diff --git a/dvc/remote/ssh.py b/dvc/remote/ssh.py index a9072318f..1a2f6ee5e 100644 --- a/dvc/remote/ssh.py +++ b/dvc/remote/ssh.py @@ -70,7 +70,7 @@ class RemoteSSH(RemoteBase): or parsed.username or getpass.getuser() ) - self.prefix = parsed.path + self.prefix = parsed.path or "/" self.port = ( config.get(Config.SECTION_REMOTE_PORT) or parsed.port diff --git a/tests/unit/remote/ssh.py b/tests/unit/remote/ssh.py index ad768806f..30a646a3e 100644 --- a/tests/unit/remote/ssh.py +++ b/tests/unit/remote/ssh.py @@ -51,6 +51,11 @@ class TestRemoteSSH(TestCase): self.assertEqual(remote.port, remote.DEFAULT_PORT) self.assertEqual(remote.prefix, path) + def test_no_path(self): + config = {"url": "ssh://127.0.0.1"} + remote = RemoteSSH(None, config) + self.assertEqual(remote.prefix, "/") + def test_port(self): url = "ssh://127.0.0.1/path/to/dir" config = {"url": url}