Aider-AI / aider

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

Uncaught BadObject in loose.py line 143 #1413

Closed robert-at-pretension-io closed 1 month ago

robert-at-pretension-io commented 1 month ago

Aider version: 0.54.13.dev46+gf3cce954 Python version: 3.12.3 Platform: macOS-14.6.1-x86_64-i386-64bit Python implementation: CPython Virtual environment: Yes OS: Darwin 23.6.0 (64bit) Git version: git version 2.39.3 (Apple Git-146)

An uncaught exception occurred:

Traceback (most recent call last):
  File "loose.py", line 132, in _map_loose_object
    return file_contents_ro_filepath(db_path, flags=self._fd_open_flags)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "util.py", line 204, in file_contents_ro_filepath
    fd = os.open(filepath, os.O_RDONLY | getattr(os, 'O_BINARY', 0) | flags)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/REP/Projects/go_lang_templ_htmx_experiment/.git/objects/9c/f38c196fdc83ffcdf7ea36d513b05e9a4c84c8'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 694, 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 257, in get_tracked_files
    commit = self.repo.head.commit
             ^^^^^^^^^^^^^^^^^^^^^
  File "symbolic.py", line 297, in _get_commit
    obj = self._get_object()
          ^^^^^^^^^^^^^^^^^^
  File "symbolic.py", line 288, in _get_object
    return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "base.py", line 149, in new_from_sha
    oinfo = repo.odb.info(sha1)
            ^^^^^^^^^^^^^^^^^^^
  File "base.py", line 210, in info
    return self._db_query(sha).info(sha)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "loose.py", line 154, in info
    m = self._map_loose_object(sha)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "loose.py", line 143, in _map_loose_object
    raise BadObject(sha) from e
gitdb.exc.BadObject: BadObject: b'9cf38c196fdc83ffcdf7ea36d513b05e9a4c84c8'
paul-gauthier commented 1 month ago

Thanks for trying aider and filing this issue.

The fix is available in the main branch. You can get it by installing the latest version from github:

aider --install-main-branch

# or...

python -m pip install --upgrade git+https://github.com/paul-gauthier/aider.git

If you have a chance to try it, let me know if it works better for you.