Aider-AI / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
20.96k stars 1.94k forks source link

Uncaught InvalidGitRepositoryError in base.py line 289 #1954

Closed adek closed 2 weeks ago

adek commented 2 weeks ago

I'm getting this error while trying to use in my project (quite a big codebase).

Aider version: 0.59.1 Python version: 3.11.7 Platform: macOS-14.6.1-arm64-arm-64bit Python implementation: CPython Virtual environment: No OS: Darwin 23.6.0 (64bit) Git version: git version 2.44.0

An uncaught exception occurred:

Traceback (most recent call last):
  File "aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 506, in main
    right_repo_root = guessed_wrong_repo(io, git_root, fnames, git_dname)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "main.py", line 59, in guessed_wrong_repo
    check_repo = Path(GitRepo(io, fnames, git_dname).root).resolve()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 93, in __init__
    self.repo = git.Repo(repo_paths.pop(), odbt=git.GitDB)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "base.py", line 289, in __init__
    raise InvalidGitRepositoryError(epath)
git.exc.InvalidGitRepositoryError: /Users/...

There is an issue with this git repo and I don't know why. Git is listing files properly. Am I missing something in git config? Is it a problem when I got many branches (still one is active and I believe aider is working with the active one).

adek commented 2 weeks ago

I tried: Already tried this: git update-index --index-version=2 git update-index --no-skip-worktree

But it's not helping. show index version is showing me 2

Also. What I found.

aider is looking in a wrong directory - I don't know why.

I change directory structure to simplify things for aider.

I changed the structure to:

/Users/adrian/AndroidStudioProjects/{hidden}

And now error:

File "/Users/adrian/miniconda3/lib/python3.11/site-packages/git/repo/base.py", line 289, in init
    raise InvalidGitRepositoryError(epath)
git.exc.InvalidGitRepositoryError: /Users/adrian/AndroidStudioProjects

So it's checking wrong dir. I'm running aider here: /Users/adrian/AndroidStudioProjects/{hidden} where I have the whole .git stuff.

I have other projects in /Users/adrian/AndroidStudioProjects/{otherHiddenProject} and it works.

With this one. It's looking in a wrong directory.