Open daniel-nimptsch opened 1 year ago
Thanks for trying aider and reporting this issue.
It looks like your git repo may be using a newer index format, which might not be supported by GitPython.
This GitPython issue has some more info and workarounds. You might want to try git update-index --no-skip-worktree
based on that issue.
I tried git update-index --no-skip-worktree
and unfortunately it did not solve the issue. I was able to launch aider in my project by copying it and then removing .git
. However, after trying to add a file, it breaks again:
Aider v0.12.0
Model: gpt-4
Git repo: .git
Repo-map: universal-ctags using 1024 tokens
Added pipeline_scripts_dn.R to the chat.
Adding /var/home/soye/Projects/pipeline_scripts_dn_aider/pipeline_scripts_dn.R to git
Use /help to see in-chat commands, run with --help to see cmd line args
Git repo has uncommitted changes.
diff --git a/pipeline_scripts_dn.R b/pipeline_scripts_dn.R
new file mode 100644
index 0000000..e69de29
Traceback (most recent call last):
File "/var/home/soye/.mambaforge/envs/aider-chat/bin/aider", line 8, in <module>
sys.exit(main())
^^^^^^
File "/var/home/soye/.mambaforge/envs/aider-chat/lib/python3.11/site-packages/aider/main.py", line 518, in main
coder.dirty_commit()
File "/var/home/soye/.mambaforge/envs/aider-chat/lib/python3.11/site-packages/aider/coders/base_coder.py", line 880, in dirty_commit
self.last_asked_for_commit_time = self.get_last_modified()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/home/soye/.mambaforge/envs/aider-chat/lib/python3.11/site-packages/aider/coders/base_coder.py", line 722, in get_last_modified
files = [Path(fn) for fn in self.get_all_abs_files() if Path(fn).exists()]
^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/home/soye/.mambaforge/envs/aider-chat/lib/python3.11/site-packages/aider/coders/base_coder.py", line 717, in get_all_abs_files
files = self.get_all_relative_files()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/home/soye/.mambaforge/envs/aider-chat/lib/python3.11/site-packages/aider/coders/base_coder.py", line 710, in get_all_relative_files
files = self.repo.get_tracked_files()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/home/soye/.mambaforge/envs/aider-chat/lib/python3.11/site-packages/aider/repo.py", line 181, in get_tracked_files
staged_files = [path for path, _ in index.entries.keys()]
^^^^^^^^^^^^^
File "/var/home/soye/.mambaforge/envs/aider-chat/lib/python3.11/site-packages/gitdb/util.py", line 253, in __getattr__
self._set_cache_(attr)
File "/var/home/soye/.mambaforge/envs/aider-chat/lib/python3.11/site-packages/git/index/base.py", line 149, in _set_cache_
self._deserialize(stream)
File "/var/home/soye/.mambaforge/envs/aider-chat/lib/python3.11/site-packages/git/index/base.py", line 177, in _deserialize
self.version, self.entries, self._extension_data, _conten_sha = read_cache(stream)
^^^^^^^^^^^^^^^^^^
File "/var/home/soye/.mambaforge/envs/aider-chat/lib/python3.11/site-packages/git/index/fun.py", line 245, in read_cache
version, num_entries = read_header(stream)
^^^^^^^^^^^^^^^^^^^
File "/var/home/soye/.mambaforge/envs/aider-chat/lib/python3.11/site-packages/git/index/fun.py", line 212, in read_header
assert version in (1, 2)
^^^^^^^^^^^^^^^^^
AssertionError
Ok, I am glad to hear you found a good workaround for your git repo.
He actually, didn't found a workaround :-) Besides I have the same issue
Same issue here, @paul-gauthier you might be able to reproduce on your side, the repo is https://github.com/status-im/status-mobile, it's a large repo
Aider v0.18.0
This works for me:
git update-index --index-version=2
I'm also hitting this issue (see below), but unfortunately none of the workarounds worked for me. Curiously, I don't seem to be getting it in my other repo.
Workarounds tried:
git update-index --index-version=2
git update-index --no-skip-worktree
Error:
$ aider --openai-api-key sk-xxx-...-zzz
Aider v0.30.1
Models: gpt-4-1106-preview with udiff edit format, weak model gpt-3.5-turbo
Traceback (most recent call last):
File "/Users/danielwaltrip/.local/bin/aider", line 8, in <module>
sys.exit(main())
^^^^^^
... (more stack info)
File "/Users/danielwaltrip/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/git/index/fun.py", line 210, in read_header
assert version in (1, 2)
^^^^^^^^^^^^^^^^^
AssertionError
P.S. Just wanna say I love the idea of aider. Thanks for making it as well as open sourcing it
Update: I was able to fix my issue by updating to the latest version of git (2.44) and running the git update-index --index-version=2
command. Aider is now working fine :)
The latest version of git has the option --show-index-version
for update-index. I verified that it was at 3 before and then was successfully changed to 2. Not sure what happened when I tried setting it to 2 with my older version of git (it was the system git provided by macos,git version 2.39.3 (Apple Git-145)
in this case).
For future reference, I don't believe that downgrading your index version is supported. I ended up deleting my index (while the repo was fully checked in and backed up) and running git reset.
Digging into it a little deeper, the issue is because GitPython only supports index version 1 and 2 (relevant code), and since the project is in maintenance mode it seems like there is a decent change that this won't be fixed in near future (though the GitPython maintainer is open to merging feature contributions).
Hopefully the authors successor project GitOxide will be stable and have a Python binding at some point soon.
Having the same issue.
Did you try updating the index as described earlier in this issue?
Yes, I'm not sure what the issue is:
$ ~/Projects/robusta → git update-index --show-index-version
3
$ ~/Projects/robusta → aider
Traceback (most recent call last):
File "/opt/homebrew/bin/aider", line 8, in <module>
sys.exit(main())
^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/aider/main.py", line 404, in main
coder.show_announcements()
File "/opt/homebrew/lib/python3.11/site-packages/aider/coders/base_coder.py", line 356, in show_announcements
for line in self.get_announcements():
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/aider/coders/base_coder.py", line 159, in get_announcements
num_files = len(self.repo.get_tracked_files())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/aider/repo.py", line 200, in get_tracked_files
staged_files = [path for path, _ in index.entries.keys()]
^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/gitdb/util.py", line 253, in __getattr__
self._set_cache_(attr)
File "/opt/homebrew/lib/python3.11/site-packages/git/index/base.py", line 168, in _set_cache_
self._deserialize(stream)
File "/opt/homebrew/lib/python3.11/site-packages/git/index/base.py", line 197, in _deserialize
self.version, self.entries, self._extension_data, _conten_sha = read_cache(stream)
^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/git/index/fun.py", line 252, in read_cache
version, num_entries = read_header(stream)
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/git/index/fun.py", line 210, in read_header
assert version in (1, 2)
^^^^^^^^^^^^^^^^^
AssertionError
However, I can workaround this with aider --no-git
- the git integration is not particularly important to me.
I should clarify - I know what the issue is, I just haven't looked into how to fix it!
$ git update-index --index-version=2
$ git update-index --show-index-version
3
No skip worktree works for me, but this isn't a solution, as I have to keep certain files silenced, so they do not keep popping up in Source Control changes.
Is there a better workaround?
When executing aider in an existing repo with R, Python, and Bash scripts, I get this error. When executing aider in a much smaller repo of only Python files, it works without problems. Thank you very much.
Error
aider
Details
aider --version
ctags --version