pygit2 icon indicating copy to clipboard operation
pygit2 copied to clipboard

pygit2.GitError: failed to parse supported auth schemes: The operation identifier is not valid.

Open PranjaliParnerkar opened this issue 2 years ago • 4 comments

I am trying to clone private github repository using pygit2 module but getting the below error.

Traceback (most recent call last):
  File ".\test2.py", line 29, in <module>
    repoClone = pygit2.clone_repository(repo_from_template.clone_url, 'C://TestRepo', callbacks=callbacks)
  File "C:\Anaconda3\lib\site-packages\pygit2\__init__.py", line 222, in clone_repository
    payload.check_error(err)
  File "C:\Anaconda3\lib\site-packages\pygit2\callbacks.py", line 93, in check_error
    check_error(error_code)
  File "C:\Anaconda3\lib\site-packages\pygit2\errors.py", line 65, in check_error
    raise GitError(message)
_pygit2.GitError: failed to parse supported auth schemes: The operation identifier is not valid.

Below is the source code I am using

import pygit2
import config_
from github import Github

g = Github(<personal access token>,base_url='https://api.github.com')
github_user = g.get_user()
org = g.get_organization(<org-name>)

repo_from_template=org.create_repo(name='TestRepo',private=True)

credentials = pygit2.UserPass(github_user.login, <personal access token>)
callbacks = pygit2.RemoteCallbacks(credentials=credentials)
repoClone = pygit2.clone_repository(repo_from_template.clone_url, 'C://TestRepo', callbacks=callbacks)

I am using python 3.9 and have tried pygit2 version 1.10.1 and 1.12.0 and both are giving the same error. Are there any changes made to the callbacks recently which is creating this issue?

PranjaliParnerkar avatar Jul 07 '23 09:07 PranjaliParnerkar

I have the same issue

accodev avatar Jul 07 '23 18:07 accodev

I worked around the problem recompiling libgit2 to use Schannel instead of WinHTTP and now it works. Sadly we have to patch it manually since there's no pygit2 distribution for windows with libgit2 compiled with Schannel.

accodev avatar Jul 13 '23 10:07 accodev

@accodev do you have an example of how you switch them over?

GeorgeTTD avatar Aug 18 '23 11:08 GeorgeTTD

The process is pretty straight forward, but I strongly advise against using this in production:

  • Clone the libgit2 repo: https://github.com/libgit2/libgit2
  • Open up a Visual Studio Developer command prompt (I used VS2022 Community Edition) and change directory to where the project was cloned
$ mkdir build && cd build
$ cmake .. -DUSE_HTTPS=Schannel
$ cmake --build . --config Release
$ cmake --install . --config Release --prefix /path/to/your/pygit2/installation

You can either use cmake --install (with a correct --prefix) or copy the git2.dll manually to where pygit2 is installed, e.g.: C:\Users\<your_user>\AppData\Local\Programs\Python\Python311\Lib\site-packages\pygit2

accodev avatar Aug 18 '23 19:08 accodev