paul-gauthier / aider

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

Uncaught ValueError in pathlib.py line 682 #1774

Open th3w1zard1 opened 3 days ago

th3w1zard1 commented 3 days ago

Aider version: 0.57.1 Python version: 3.12.3 Platform: Windows-10-10.0.19045-SP0 Python implementation: CPython Virtual environment: No OS: Windows 10 (64bit) Git version: git version 2.45.2.windows.1

An uncaught exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "__main__.py", line 7, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 709, in main
    coder.run()
  File "base_coder.py", line 723, in run
    self.run_one(user_message, preproc)
  File "base_coder.py", line 760, in run_one
    message = self.preproc_user_input(user_message)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "base_coder.py", line 749, in preproc_user_input
    return self.commands.run(inp)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "commands.py", line 221, in run
    return self.do_run(matching_commands[0][1:], rest_inp)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "commands.py", line 196, in do_run
    return cmd_method(args)
           ^^^^^^^^^^^^^^^^
  File "commands.py", line 946, in cmd_code
    return self._generic_chat_command(args, self.coder.main_model.edit_format)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "commands.py", line 955, in _generic_chat_command
    coder = Coder.create(
            ^^^^^^^^^^^^^
  File "base_coder.py", line 152, in create
    res = coder(main_model, io, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "base_coder.py", line 343, in __init__
    if self.repo and self.repo.ignored_file(fname):
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 332, in ignored_file
    result = self.ignored_file_raw(fname)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 338, in ignored_file_raw
    fname_path = Path(self.normalize_path(fname))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 299, in normalize_path
    path = str(Path(PurePosixPath((Path(self.root) / path).relative_to(self.root))))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pathlib.py", line 682, in relative_to
    raise ValueError(f"{str(self)!r} is not in the subpath of {str(other)!r}")
ValueError: 'C:\\Users\\*****\\AppData\\Local\\Temp\\tmpe8hjgkw9\\clipboard_image.png' is not in the subpath of 'C:\\GitHub\\PyKotor\\Libraries\\Utility\\src\\utility\\ui_libraries\\qt'

I put a clipboard image in the chat, typed my message, pressed enter, immediately Ctrl+C because I remembered something i wanted to add to the message, retyped a new message, pressed enter, and was greeted with this interesting stack trace. Might want to check if is_relative_to or break things into local variables? The exception is a bit difficult to read, not sure why so much path normalization needs to be happening? What's wrong with os.path.normpath...?

fry69 commented 3 days ago

Thank you for filing this issue.

As far as I know this is a necessary test for a known limitation of how the clipboard/pasting images works on Windows. But maybe @paul-gauthier has more insight into this problem?