From 52d04430db7498989272182349044e12ba338630 Mon Sep 17 00:00:00 2001 From: contributor Date: Mon, 23 Jun 2025 12:45:45 +0300 Subject: [PATCH] feat: Auto-create parent directories for chat history files 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' ``` --- aider/io.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aider/io.py b/aider/io.py index f8cf78cd3..f0000e965 100644 --- a/aider/io.py +++ b/aider/io.py @@ -731,6 +731,7 @@ class InputOutput: if not self.input_history_file: return try: + Path(self.input_history_file).parent.mkdir(parents=True, exist_ok=True) FileHistory(self.input_history_file).append_string(inp) # Also add to the in-memory history if it exists if self.prompt_session and self.prompt_session.history: @@ -1116,6 +1117,7 @@ class InputOutput: text += "\n" if self.chat_history_file is not None: try: + self.chat_history_file.parent.mkdir(parents=True, exist_ok=True) with self.chat_history_file.open("a", encoding=self.encoding, errors="ignore") as f: f.write(text) except (PermissionError, OSError) as err: