Skip to content

feat: Auto-create parent directories for chat history files #4257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

contributor
Copy link
Contributor

Automatically create parent directories when writing to chat-history-file and input-history-file.

Previously, aider would fail to write history files if the parent directory didn't exist, showing errors like

Warning: Unable to write to chat history file .chat/.aider.chat.history.md.
[Errno 2] No such file or directory: '.chat/.aider.chat.history.md'

This change adds parent.mkdir(parents=True, exist_ok=True) before writing to both:

  • chat-history-file
  • input-history-file

Fixes the issue where users couldn't use paths like .chat/aider.chat.history.md in their configuration without first manually creating the .chat directory.

This prevents aider startup errors like:
```
Warning: Unable to write to chat history file .chat/.aider.chat.history.md.
[Errno 2] No such file or directory: '.chat/.aider.chat.history.md'
```
@contributor contributor force-pushed the chat-history-files-auto-create-dir branch from 5326b1d to 52d0443 Compare June 23, 2025 11:22
@contributor
Copy link
Contributor Author

This change adds parent.mkdir(parents=True, exist_ok=True) before writing to both:

moved creation to InputOutput constructor to check/create only once (decreases number of IO operations)

@paul-gauthier paul-gauthier merged commit d85078a into Aider-AI:main Jun 25, 2025
1 check passed
@contributor
Copy link
Contributor Author

contributor commented Jun 25, 2025

Hi @paul-gauthier
There was a bug in merged commit, sorry
Somehow, the PR checks didn't catch failing tests

Here is PR to fix #4271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants