dvc icon indicating copy to clipboard operation
dvc copied to clipboard

`get`: fails to clone because "no valid credentials provided"

Open guyrosin opened this issue 4 years ago • 30 comments

Bug Report

Description

When executing dvc get or dvc update, a "failed to clone repo" error appears, which originates from a "dulwich.client.HTTPUnauthorized: No valid credentials provided" error. This started happening without any clear reason, after several weeks of working with DVC with no problem.

Related issues: https://github.com/jelmer/dulwich/issues/882, https://github.com/python-poetry/poetry/pull/5428

Environment information

Output of dvc doctor:

$ dvc doctor
DVC version: 2.10.2 (pip)
---------------------------------
Platform: Python 3.9.12 on macOS-12.2.1-x86_64-i386-64bit
Supports:
        hdfs (fsspec = 2022.3.0, pyarrow = 7.0.0),
        webhdfs (fsspec = 2022.3.0),
        http (aiohttp = 3.8.1, aiohttp-retry = 2.4.6),
        https (aiohttp = 3.8.1, aiohttp-retry = 2.4.6)
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk1s1s1
Caches: local
Remotes: https
Workspace directory: apfs on /dev/disk1s1s1
Repo: dvc, git

Additional Information (if any):

$ dvc get https://dagshub.com/aviv/data-repo README.md -v
2022-05-01 16:37:20,420 DEBUG: Creating external repo https://dagshub.com/aviv/data-repo@None
2022-05-01 16:37:20,420 DEBUG: erepo: git clone 'https://dagshub.com/aviv/data-repo' to a temporary dir
2022-05-01 16:37:20,888 DEBUG: Removing '/Users/guyrosin/code/playground/test/.B66n2XDC3RLgwwhXr8AoUr'                                                                           
2022-05-01 16:37:20,888 ERROR: failed to get 'README.md' from 'https://dagshub.com/aviv/data-repo' - Failed to clone repo 'https://dagshub.com/aviv/data-repo' to '/var/folders/2x/3n66lzcd1gg06nk_sjjq319w0000gn/T/tmpv7y9y9z5dvc-clone'
------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/scmrepo/git/backend/dulwich/__init__.py", line 193, in clone
    repo = clone_from()
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/porcelain.py", line 443, in clone
    return client.clone(
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/client.py", line 535, in clone
    result = self.fetch(path, target, progress=progress, depth=depth)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/client.py", line 601, in fetch
    result = self.fetch_pack(
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/client.py", line 2047, in fetch_pack
    refs, server_capabilities, url = self._discover_references(
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/client.py", line 1908, in _discover_references
    resp, read = self._http_request(url, headers, allow_compression=True)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/client.py", line 2189, in _http_request
    raise HTTPUnauthorized(resp.getheader("WWW-Authenticate"), url)
dulwich.client.HTTPUnauthorized: No valid credentials provided

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/scm.py", line 126, in clone
    git = Git.clone(url, to_path, progress=pbar.update_git, **kwargs)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/scmrepo/git/__init__.py", line 143, in clone
    backend.clone(url, to_path, **kwargs)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/scmrepo/git/backend/dulwich/__init__.py", line 196, in clone
    raise CloneError(url, to_path) from exc
scmrepo.exceptions.CloneError: Failed to clone repo 'https://dagshub.com/aviv/data-repo' to '/var/folders/2x/3n66lzcd1gg06nk_sjjq319w0000gn/T/tmpv7y9y9z5dvc-clone'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/commands/get.py", line 39, in _get_file_from_repo
    Repo.get(
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/repo/get.py", line 49, in get
    with external_repo(
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/external_repo.py", line 39, in external_repo
    path = _cached_clone(url, rev, for_write=for_write)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/external_repo.py", line 165, in _cached_clone
    clone_path, shallow = _clone_default_branch(url, rev, for_write=for_write)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/funcy/decorators.py", line 45, in wrapper
    return deco(call, *dargs, **dkwargs)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/funcy/flow.py", line 274, in wrap_with
    return call()
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/funcy/decorators.py", line 66, in __call__
    return self._func(*self._args, **self._kwargs)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/external_repo.py", line 235, in _clone_default_branch
    git = clone(url, clone_path)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/scm.py", line 131, in clone
    raise CloneError(str(exc))
dvc.scm.CloneError: Failed to clone repo 'https://dagshub.com/aviv/data-repo' to '/var/folders/2x/3n66lzcd1gg06nk_sjjq319w0000gn/T/tmpv7y9y9z5dvc-clone'
------------------------------------------------------------

guyrosin avatar May 01 '22 14:05 guyrosin

Hi, I see that https://dagshub.com/aviv/data-repo gives me a 404. I'm assuming this is because that is a private repo (either that or it has been deleted)

Since you're saying that this started happening recently was this changed to private (deleted?) recently?

dtrifiro avatar May 01 '22 17:05 dtrifiro

Thanks @dtrifiro, this repo has always been private. I've been using it for several weeks already with no problem. It seems this error started appearing after I updated DVC to v2.10! After downgrading to v2.9.3 everything seems to work.

Here's the whole debugging story FYI: Initially I used DVC v2.10.3. I tried running dvc get and dvc import with two git URLs: https://dagshub.com/aviv/data-repo, and using an access token (https://{user}:{token}@dagshub.com/aviv/data-repo). Both didn't work. I've downgraded DVC to v2.10.1 and it looked much better, but still weird...

  • First of all, dvc get and dvc import actually worked!
  • They worked only when using the URL with the user:token prefix! Otherwise I got the same error as before ("No valid credentials provided")
  • After the successful dvc import, if I executed the same command again without any file changes, (almost) the same error appeared: "unexpected error - No valid credentials provided".
  • But if I push to dvc and git and then run dvc import, it worked...
  • Finally, I downgraded DVC to v2.9.3 (the last version I remember worked 100%), and now running dvc import without any file changes results in "'data.dvc' didn't change, skipping", as it should've been. It works even with the standard HTTPS URL (without the user:token prefix), as it should.

guyrosin avatar May 02 '22 07:05 guyrosin

Can confirm this is happening, starting from https://github.com/iterative/dvc/pull/7554

dtrifiro avatar May 02 '22 09:05 dtrifiro

Still crashes with the same error using dvc v2.11.0 :(

❯ dvc get https://dagshub.com/aviv/data-repo README.md -v
2022-06-14 17:15:43,776 DEBUG: Creating external repo https://dagshub.com/aviv/data-repo@None
2022-06-14 17:15:43,776 DEBUG: erepo: git clone 'https://dagshub.com/aviv/data-repo' to a temporary dir
2022-06-14 17:15:44,238 DEBUG: Removing '/Users/guyrosin/code/playground/.eqznXKcQmyfXK5wC87zMvn'                                                                               
2022-06-14 17:15:44,238 ERROR: failed to get 'README.md' from 'https://dagshub.com/aviv/data-repo' - Failed to clone repo 'https://dagshub.com/aviv/data-repo' to '/var/folders/2x/3n66lzcd1gg06nk_sjjq319w0000gn/T/tmp_2h5e0wzdvc-clone'
------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/scmrepo/git/backend/dulwich/__init__.py", line 196, in clone
    repo = clone_from()
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/porcelain.py", line 443, in clone
    return client.clone(
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/client.py", line 622, in clone
    result = self.fetch(path, target, progress=progress, depth=depth)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/client.py", line 699, in fetch
    result = self.fetch_pack(
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/client.py", line 2075, in fetch_pack
    refs, server_capabilities, url = self._discover_references(
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/client.py", line 1934, in _discover_references
    resp, read = self._http_request(url, headers, allow_compression=True)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dulwich/client.py", line 2218, in _http_request
    raise HTTPUnauthorized(resp.getheader("WWW-Authenticate"), url)
dulwich.client.HTTPUnauthorized: No valid credentials provided

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/scm.py", line 145, in clone
    git = Git.clone(url, to_path, progress=pbar.update_git, **kwargs)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/scmrepo/git/__init__.py", line 143, in clone
    backend.clone(url, to_path, **kwargs)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/scmrepo/git/backend/dulwich/__init__.py", line 199, in clone
    raise CloneError(url, to_path) from exc
scmrepo.exceptions.CloneError: Failed to clone repo 'https://dagshub.com/aviv/data-repo' to '/var/folders/2x/3n66lzcd1gg06nk_sjjq319w0000gn/T/tmp_2h5e0wzdvc-clone'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/commands/get.py", line 39, in _get_file_from_repo
    Repo.get(
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/repo/get.py", line 50, in get
    with external_repo(
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/external_repo.py", line 39, in external_repo
    path = _cached_clone(url, rev, for_write=for_write)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/external_repo.py", line 169, in _cached_clone
    clone_path, shallow = _clone_default_branch(url, rev, for_write=for_write)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/funcy/decorators.py", line 45, in wrapper
    return deco(call, *dargs, **dkwargs)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/funcy/flow.py", line 274, in wrap_with
    return call()
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/funcy/decorators.py", line 66, in __call__
    return self._func(*self._args, **self._kwargs)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/external_repo.py", line 239, in _clone_default_branch
    git = clone(url, clone_path)
  File "/Users/guyrosin/miniconda3/envs/rdkit-test/lib/python3.9/site-packages/dvc/scm.py", line 150, in clone
    raise CloneError(str(exc))
dvc.scm.CloneError: Failed to clone repo 'https://dagshub.com/aviv/data-repo' to '/var/folders/2x/3n66lzcd1gg06nk_sjjq319w0000gn/T/tmp_2h5e0wzdvc-clone'
------------------------------------------------------------
2022-06-14 17:15:44,258 DEBUG: Analytics is enabled.
2022-06-14 17:15:44,308 DEBUG: Trying to spawn '['daemon', '-q', 'analytics', '/var/folders/2x/3n66lzcd1gg06nk_sjjq319w0000gn/T/tmpkmarbkqi']'
2022-06-14 17:15:44,310 DEBUG: Spawned '['daemon', '-q', 'analytics', '/var/folders/2x/3n66lzcd1gg06nk_sjjq319w0000gn/T/tmpkmarbkqi']'

Output of dvc doctor:

$ dvc doctor
DVC version: 2.11.0 (pip)
---------------------------------
Platform: Python 3.9.12 on macOS-12.3.1-x86_64-i386-64bit
Supports:
        gdrive (pydrive2 = 1.10.1),
        hdfs (fsspec = 2022.5.0, pyarrow = 8.0.0),
        webhdfs (fsspec = 2022.5.0),
        http (aiohttp = 3.8.1, aiohttp-retry = 2.4.6),
        https (aiohttp = 3.8.1, aiohttp-retry = 2.4.6)
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk1s1s1
Caches: local
Remotes: https
Workspace directory: apfs on /dev/disk1s1s1
Repo: dvc, git

guyrosin avatar Jun 14 '22 14:06 guyrosin

@guyrosin does using the explicit username+token in the URL (https://{user}:{token}@dagshub.com/aviv/data-repo) work for you in 2.11.0?

the underlying credentials issue (without providing the acess token) is the same as https://github.com/iterative/dvc/issues/6586 and is currently being worked on, but in 2.11 I would expect including the token in your repo URL to work

pmrowla avatar Jun 15 '22 01:06 pmrowla

@pmrowla Yeah, it works! Quick followup question: there's no way to specify credentials for dvc update, right? (that's what currently keeps me from updating to v2.11)

guyrosin avatar Jun 20 '22 07:06 guyrosin

@guyrosin if you manually edit the .dvc file to include the token in the dependency url field I think dvc update will use the token. But otherwise you will need to wait for the linked fix to be merged & released

pmrowla avatar Jun 21 '22 06:06 pmrowla

I am still experiencing similar issues with dvc 2.12.0 with authentications, even with providing explicitly user and token in the repo link.

dulwich.client.HTTPUnauthorized: No valid credentials provided

The only fix is to revert back to 2.9.13.

Any updates on this issue?

vaxherra avatar Jul 01 '22 11:07 vaxherra

@vaxherra It's being addressed upstream in https://github.com/jelmer/dulwich/pull/976. Once that is merged, we should be able to support it in the following DVC release.

dberenbaum avatar Jul 01 '22 14:07 dberenbaum

This is fixed in 2.25.0

dtrifiro avatar Sep 15 '22 06:09 dtrifiro

This is still happening for me after upgrading from version 2.9.5 to version 2.30.0

Environment information

Output of dvc doctor:

$ dvc doctor
DVC version: 2.30.0 (pip)
---------------------------------
Platform: Python 3.9.12 on macOS-12.6-x86_64-i386-64bit
Subprojects:
	dvc_data = 0.17.1
	dvc_objects = 0.7.0
	dvc_render = 0.0.12
	dvc_task = 0.1.3
	dvclive = 0.11.0
	scmrepo = 0.1.1
Supports:
	http (aiohttp = 3.8.3, aiohttp-retry = 2.8.3),
	https (aiohttp = 3.8.3, aiohttp-retry = 2.8.3)
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk1s1s1
Caches: local
Remotes: https
Workspace directory: apfs on /dev/disk1s1s1
Repo: dvc, git

Verbose output of dvc update:

$ dvc update data/dry.dvc -v
2022-10-19 12:17:55,342 DEBUG: Creating external repo https://dagshub.com/mana-bio/data-repo@None
2022-10-19 12:17:55,342 DEBUG: erepo: git clone 'https://dagshub.com/mana-bio/data-repo' to a temporary dir
2022-10-19 12:17:55,902 ERROR: failed update data - Failed to clone repo 'https://dagshub.com/mana-bio/data-repo' to '/var/folders/r2/qc7fk3l172d1wc1l6r1gyzcm0000gn/T/tmpla66ns6fdvc-clone'
------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/scmrepo/git/backend/dulwich/__init__.py", line 200, in clone
    repo = clone_from()
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dulwich/porcelain.py", line 538, in clone
    return client.clone(
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dulwich/client.py", line 760, in clone
    result = self.fetch(path, target, progress=progress, depth=depth)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dulwich/client.py", line 837, in fetch
    result = self.fetch_pack(
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dulwich/client.py", line 2075, in fetch_pack
    refs, server_capabilities, url = self._discover_references(
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dulwich/client.py", line 1934, in _discover_references
    resp, read = self._http_request(url, headers)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dulwich/client.py", line 2215, in _http_request
    raise HTTPUnauthorized(resp.getheader("WWW-Authenticate"), url)
dulwich.client.HTTPUnauthorized: No valid credentials provided

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dvc/scm.py", line 145, in clone
    git = Git.clone(url, to_path, progress=pbar.update_git, **kwargs)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/scmrepo/git/__init__.py", line 143, in clone
    backend.clone(url, to_path, **kwargs)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/scmrepo/git/backend/dulwich/__init__.py", line 203, in clone
    raise CloneError(url, to_path) from exc
scmrepo.exceptions.CloneError: Failed to clone repo 'https://dagshub.com/mana-bio/data-repo' to '/var/folders/r2/qc7fk3l172d1wc1l6r1gyzcm0000gn/T/tmpla66ns6fdvc-clone'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dvc/commands/update.py", line 16, in run
    self.repo.update(
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dvc/repo/__init__.py", line 49, in wrapper
    return f(repo, *args, **kwargs)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dvc/repo/update.py", line 40, in update
    stage.update(
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dvc/stage/__init__.py", line 452, in update
    update_import(
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dvc/stage/imports.py", line 23, in update_import
    stage.deps[0].update(rev=rev)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dvc/dependency/repo.py", line 87, in update
    with self._make_repo(locked=False) as repo:
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dvc/external_repo.py", line 39, in external_repo
    path = _cached_clone(url, rev, for_write=for_write)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dvc/external_repo.py", line 169, in _cached_clone
    clone_path, shallow = _clone_default_branch(url, rev, for_write=for_write)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/funcy/decorators.py", line 45, in wrapper
    return deco(call, *dargs, **dkwargs)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/funcy/flow.py", line 274, in wrap_with
    return call()
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/funcy/decorators.py", line 66, in __call__
    return self._func(*self._args, **self._kwargs)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dvc/external_repo.py", line 239, in _clone_default_branch
    git = clone(url, clone_path)
  File "/Users/aviv/miniconda3/envs/playground/lib/python3.9/site-packages/dvc/scm.py", line 150, in clone
    raise CloneError(str(exc))
dvc.scm.CloneError: Failed to clone repo 'https://dagshub.com/mana-bio/data-repo' to '/var/folders/r2/qc7fk3l172d1wc1l6r1gyzcm0000gn/T/tmpla66ns6fdvc-clone'
------------------------------------------------------------
2022-10-19 12:17:55,915 DEBUG: Analytics is enabled.
2022-10-19 12:17:55,984 DEBUG: Trying to spawn '['daemon', '-q', 'analytics', '/var/folders/r2/qc7fk3l172d1wc1l6r1gyzcm0000gn/T/tmphlvsybrd']'
2022-10-19 12:17:55,986 DEBUG: Spawned '['daemon', '-q', 'analytics', '/var/folders/r2/qc7fk3l172d1wc1l6r1gyzcm0000gn/T/tmphlvsybrd']'

avivio avatar Oct 19 '22 09:10 avivio

@avivio This looks like a private repo, right? If so, the credentials need to be found either in the URL or in a git credential helper.

Are you able to successfully do git clone https://dagshub.com/mana-bio/data-repo and do you need to enter any prompts to do so?

dberenbaum avatar Oct 25 '22 16:10 dberenbaum

@dberenbaum @avivio Asked @dtrifiro , he said that:

I've had a quick look. Need to fix the clone method in scmrepo.git.backends.dulwich, it doesn't use the GitCredentials client. This needs to also be done in other methods which use get_transport_and_path

which is a bug in his monkeypatch in scmrepo. I'll link the issue here in a sec.

efiop avatar Oct 25 '22 19:10 efiop

Here's what I get on a private dagshub repo:

# Fails without credentials
$ dvc get https://dagshub.com/dberenbaum/lstm_seq2seq README.md
ERROR: failed to get 'README.md' from 'https://dagshub.com/dberenbaum/lstm_seq2seq' - Failed to clone repo 'https://dagshub.com/dberenbaum/lstm_seq2seq' to '/var/folders/24/99_tf1xj3vx8k1k_jkdmnhq00000gn/T/tmpak9j7bi1dvc-clone'

# Cache credentials in git
$ git config credential.helper cache
$ git clone https://dagshub.com/dberenbaum/lstm_seq2seq
Cloning into 'lstm_seq2seq'...
Username for 'https://dagshub.com/': dberenbaum
Password for 'https://[email protected]/':
remote: Enumerating objects: 91, done.
remote: Counting objects: 100% (91/91), done.
remote: Compressing objects: 100% (67/67), done.
remote: Total 91 (delta 32), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (91/91), 9.30 KiB | 3.10 MiB/s, done.
Resolving deltas: 100% (32/32), done.

# This time it succeeds
$ dvc get https://dagshub.com/dberenbaum/lstm_seq2seq README.md

What else is expected here?

dberenbaum avatar Oct 26 '22 15:10 dberenbaum

I'm facing the same problem on macOS while there's no problem on Linux (Ubuntu 20.04). dvc get/dvc import/dvc pull fails with the error:

dvc.scm.CloneError: Failed to clone repo ...

I'm using DVC v2.34.2. It would be great if this problem could get fixed with high priority because it prevents our macOS users from using DVC. :slightly_frowning_face:

sisp avatar Nov 18 '22 09:11 sisp

@sisp Thanks for reporting. It's hard to tell in which scenarios this breaks, but it's clear at this point that it's causing enough issues that we need to change the credential handling, and it's been made a high priority.

In the meantime, can you try this workaround?

Om Mac I had to ssh-add -AK ~/.ssh/id_rsa to enable the agent and keychain: https://github.com/ronf/asyncssh/discussions/522

Originally posted by @shcheklein in https://github.com/iterative/dvc/issues/7702#issuecomment-1304895509

dberenbaum avatar Nov 18 '22 14:11 dberenbaum

@dberenbaum Thanks for hinting at the possible workaround. I've forwarded your comment to @dekromp who is using a Mac and got this error. We'll report back. Good to know this is a priority.

sisp avatar Nov 18 '22 15:11 sisp

It seems like maybe the current implementation fails to retrieve credentials from the OSX keychain. Another possible workaround mentioned above is to try git config credential.helper cache so that git caches the credentials temporarily for reuse. This should work for non-ssh scenarios.

dberenbaum avatar Nov 18 '22 15:11 dberenbaum

Hi @dberenbaum, thanks for the workaround. Unfortunately it did not work me. By the way, the provided workaround requires some additional steps mentioned here if the ssh key is not protected by a passphrase: https://github.com/jirsbek/SSH-keys-in-macOS-Sierra-keychain/issues/15#issuecomment-435716793

Output of dvc doctor:

DVC version: 2.34.2 (pip)
---------------------------------
Platform: Python 3.8.12 on macOS-12.6.1-x86_64-i386-64bit
Subprojects:
	dvc_data = 0.25.3
	dvc_objects = 0.12.2
	dvc_render = 0.0.12
	dvc_task = 0.1.5
	dvclive = 1.0.1
	scmrepo = 0.1.3
Supports:
	http (aiohttp = 3.8.3, aiohttp-retry = 2.8.3),
	https (aiohttp = 3.8.3, aiohttp-retry = 2.8.3)

dekromp avatar Nov 21 '22 08:11 dekromp

Hi @dekromp and @sisp, sorry for taking so long to get back to you but I was out sick.

What credential helper are you using on mac? I can't seem to reproduce using git credential-store and git credential-osxkeychain. How did you configure the helper? Does cloning the repo using the git cli work (git clone https://<...>(?

dtrifiro avatar Nov 28 '22 14:11 dtrifiro