Aider-AI / aider

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

Following dead symlinks can crash Aider #780

Closed gwpl closed 4 months ago

gwpl commented 4 months ago

Issue

I think I've managed to find a bug (?) to crash aider. So if there are symlinks in repository to paths that do not exist. Example trace:

Use /help to see in-chat commands, run with --help to see cmd line args
Traceback (most recent call last):
  File "/home/USER/.local/bin/aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/USER/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/aider/main.py", line 533, in main
    coder.run()
  File "/home/USER/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/aider/coders/base_coder.py", line 606, in run
    new_user_message = self.run_loop()
                       ^^^^^^^^^^^^^^^
  File "/home/USER/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/aider/coders/base_coder.py", line 634, in run_loop
    self.get_addable_relative_files(),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/aider/coders/base_coder.py", line 1216, in get_addable_relative_files
    return set(self.get_all_relative_files()) - set(self.get_inchat_relative_files())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/aider/coders/base_coder.py", line 1201, in get_all_relative_files
    files = [fname for fname in files if Path(self.abs_root_path(fname)).is_file()]
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/pathlib.py", line 892, in is_file
    return S_ISREG(self.stat().st_mode)
                   ^^^^^^^^^^^
  File "/usr/lib/python3.12/pathlib.py", line 840, in stat
    return os.stat(self, follow_symlinks=follow_symlinks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: /path/to/non/existend/symlink

Version and model info

Aider v0.40.6 Models: claude-3-5-sonnet-20240620 with whole edit format, weak model claude-3-haiku-20240307

paul-gauthier commented 4 months ago

Thanks for trying aider and filing this issue.

I've pushed a fix. The change is available in the main branch. You can get it by installing the latest version from github:

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.

paul-gauthier commented 4 months 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.

gwpl commented 4 months ago

Thank you for fix and all work on aider so much!