Aider-AI / aider

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

Running a `git subtree` command in Aider causes uncaught exception #1334

Closed mbrock closed 1 month ago

mbrock commented 1 month ago

I told Aider to add a vendor repo as a subtree and it suggested doing

git subtree add --prefix vendor/ratpoison https://git.savannah.nongnu.org/git/ratpoison.git master --squash

but this command seems to crash Aider's Git parsing.

Aider version: 0.54.13.dev22+g2dc3a064.d20240904 Python version: 3.12.5 Platform: macOS-14.5-arm64-arm-64bit Python implementation: CPython Virtual environment: Yes OS: Darwin 23.5.0 (64bit) Git version: git version 2.39.3 (Apple Git-146)

An uncaught exception occurred:

Traceback (most recent call last):
  File "aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 691, in main
    coder.run()
  File "base_coder.py", line 730, in run
    self.run_one(user_message, preproc)
  File "base_coder.py", line 773, in run_one
    list(self.send_message(message))
  File "base_coder.py", line 1221, in send_message
    add_rel_files_message = self.check_for_file_mentions(content)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "base_coder.py", line 1347, in check_for_file_mentions
    mentioned_rel_fnames = self.get_file_mentions(content)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "base_coder.py", line 1322, in get_file_mentions
    addable_rel_fnames = self.get_addable_relative_files()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "base_coder.py", line 1656, in get_addable_relative_files
    all_files = set(self.get_all_relative_files())
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "base_coder.py", line 1641, in get_all_relative_files
    files = self.repo.get_tracked_files()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 266, in get_tracked_files
    for blob in commit.tree.traverse():
                ^^^^^^^^^^^^^^^^^^^^^^
  File "util.py", line 575, in _traverse
    addToStack(stack, item, branch_first, nd)
  File "util.py", line 535, in addToStack
    lst = self._get_intermediate_items(item)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "tree.py", line 207, in _get_intermediate_items
    return tuple(index_object._iter_convert_to_object(index_object._cache))
                                                      ^^^^^^^^^^^^^^^^^^^
  File "util.py", line 253, in __getattr__
    self._set_cache_(attr)
  File "tree.py", line 213, in _set_cache_
    ostream = self.repo.odb.stream(self.binsha)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "base.py", line 213, in stream
    return self._db_query(sha).stream(sha)
           ^^^^^^^^^^^^^^^^^^^
  File "base.py", line 197, in _db_query
    raise BadObject(sha)
gitdb.exc.BadObject: BadObject: b'603987a306a5cc72251a1a880058544261976078'
fry69 commented 1 month ago

subtree and submodules are currently not supported by aider as far as I know. aider can only handle one plain git repository at the moment.

This documentation may be helpful for dealing with monorepos and other huge repositories -> https://aider.chat/docs/faq.html#can-i-use-aider-in-a-large-mono-repo

paul-gauthier commented 1 month ago

Thanks for trying aider and filing this issue.

Yes, unfortunately this is not supported. Aider would have given you a more graceful error on launch, but since you changed the repo midway through your session it ended up with an uncaught exception.

paul-gauthier commented 1 month ago

I'm going to close this issue for now, but feel free to add a comment here and I will re-open or file a new issue any time.