libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.58k stars 382 forks source link

Error, Repository not found #1195

Open zdaiot opened 1 year ago

zdaiot commented 1 year ago

Suppose the git directory is repos/v8.

When the ownership of repos/v8 is test:test, initialize the repository with Python under root authority. Prompt error: _ pygit2.GitError: Repository not found at repos/v8/ .git.

When using the command chown-R test:test repos/ v8, initializing the repository with Python under root permission will not cause an error.

What is the reason for this, please?

sergiomb2 commented 1 year ago
_pygit2.GitError: Repository not found at 
pygit2.repository.Repository("/srv/git/repositories/rpmspec/nodejs-electron.git", pygit2.GIT_REPOSITORY_OPEN_BARE)

Cell In [42], line 1
----> 1 a = pygit2.repository.Repository("/srv/git/repositories/rpmspec/nodejs-electron.git", pygit2.GIT_REPOSITORY_OPEN_BARE)

File /usr/lib64/python3.11/site-packages/pygit2/repository.py:1620, in Repository.__init__(self, path, flags)
1618     if not isinstance(path, str):
1619         path = path.decode('utf-8')
-> 1620     path_backend = init_file_backend(path, flags)
1621     super().__init__(path_backend)

what is the problem ? ls /srv/git/repositories/rpmspec/nodejs-electron.git/ config description git-daemon-export-ok HEAD hooks/ info/ objects/ refs/

I'm using Fedora 37 with libgit2 1.3.2

sergiomb2 commented 1 year ago

I think I got the answer

It is the "Ownership check" since an early version when we run repo = Repository('.') we need to run with same user of the ownership of the directory

zdaiot commented 1 year ago

@sergiomb2 Thank you. Has the latest version solved this problem?