paul-gauthier / aider

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

When aider tries to create *.py file it throws OSError on Windows #603

Closed VictorBargains closed 3 weeks ago

VictorBargains commented 1 month ago

Issue


> /add *.py

No files matched '*.py'. Do you want to create
C:\Users\victorb\code\multiverse\autogen_skyseer\colab_gpt4o\02_src\*.py? yes
Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\victorb\code\multiverse\autogen_skyseer\colab_gpt4o\02_src\.venv\Scripts\aider.exe\__main__.py", line 7, in <module>
    sys.exit(main())
  File "C:\Users\victorb\code\multiverse\autogen_skyseer\colab_gpt4o\02_src\.venv\lib\site-packages\aider\main.py", line 408, in main
    coder.run()
  File "C:\Users\victorb\code\multiverse\autogen_skyseer\colab_gpt4o\02_src\.venv\lib\site-packages\aider\coders\base_coder.py", line 496, in run
    new_user_message = self.run_loop()
  File "C:\Users\victorb\code\multiverse\autogen_skyseer\colab_gpt4o\02_src\.venv\lib\site-packages\aider\coders\base_coder.py", line 523, in run_loop
    return self.commands.run(inp)
  File "C:\Users\victorb\code\multiverse\autogen_skyseer\colab_gpt4o\02_src\.venv\lib\site-packages\aider\commands.py", line 131, in run
    return self.do_run(matching_commands[0][1:], rest_inp)
  File "C:\Users\victorb\code\multiverse\autogen_skyseer\colab_gpt4o\02_src\.venv\lib\site-packages\aider\commands.py", line 105, in do_run
    return cmd_method(args)
  File "C:\Users\victorb\code\multiverse\autogen_skyseer\colab_gpt4o\02_src\.venv\lib\site-packages\aider\commands.py", line 397, in cmd_add
    fname.touch()
  File "C:\Python310\lib\pathlib.py", line 1166, in touch
    self._accessor.touch(self, mode, exist_ok)
  File "C:\Python310\lib\pathlib.py", line 331, in touch
    fd = os.open(path, flags, mode)
OSError: [Errno 22] Invalid argument: 'C:\\Users\\victorb\\code\\multiverse\\autogen_skyseer\\colab_gpt4o\\02_src\\*.py'

### Version and model info

$ aider --model gpt-4o --yes backend
Aider v0.35.0
Model: gpt-4o with diff edit format
Git repo: .git with 11 files
Repo-map: using 1024 tokens
VSCode terminal detected, pretty output has been disabled.
Use /help to see in-chat commands, run with --help to see cmd line args
────────────────────────────────────────────────────────────────────────────────────────────────────
paul-gauthier commented 4 weeks ago

Thanks for trying aider and filing this issue.

When you run with --yes aider will answer yes to every question. Sometimes that will cause unexpected actions to occur.

What are you trying to do? Why are you running with --yes and then typing /add *.py when there are no python files?

VictorBargains commented 4 weeks ago

In this case I forgot I was in a parent folder so I needed to do /add backend/*.py instead. What I would expect is that it doesn’t even ask to create a file with a wildcard because that is never possible. Second best case would be to catch the error so it just keeps the session alive even if that operation does nothing. On May 16, 2024, at 8:56 AM, paul-gauthier @.**> wrote: Thanks for trying aider and filing this issue. When you run with --yes aider will answer yes to every question. Sometimes that will cause unexpected actions to occur. What are you trying to do? Why are you running with --yes and then typing /add .py when there are no python files?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

paul-gauthier commented 4 weeks ago

Ah yes, you're right. Aider should catch the OSError.

FYI, on non-Windows, you can make files with wildcards in their names.

paul-gauthier commented 3 weeks ago

Aider fixed this issue. 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.