libgit2 / libgit2/pygit2

"ValueError: attempt to reinitialize" error from Repository.update_submodules()

Open
#995 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Description

I keep getting:
File "\GitWorkflow.py", line 126, in update_submodules
repo.update_submodules(callbacks=callbacks, init=False)
File "\lib\site-packages\pygit2\repository.py", line 108, in update_submodules
check_error(err)
File "\lib\site-packages\pygit2\errors.py", line 52, in check_error
raise ValueError(message)
ValueError: attempt to reinitialize '{path}'

Seems to be C.GIT_EEXISTS(?)

I am running:
repo.init_submodules()
repo.update_submodules(callbacks=callbacks)

Oddly, the error seems to come only from update_submodules, not init_submodules.
The folder for the submodule in question exists, but it is empty. "git submodule update" works without issue.

Am I doing something wrong?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the sequence with repo.init_submodules() followed by repo.update_submodules(callbacks=callbacks), then compare it with the working git submodule update behavior. Read the Repository.update_submodules() entry point and the reported GitWorkflow.py call site; done means identifying whether the empty submodule directory and reinitialization error indicate incorrect usage or a pygit2 bug.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.