From 0dfedecff509586054e2453abe8e0eed1e12b5e8 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 30 Aug 2024 06:47:45 -0700 Subject: [PATCH] fixes #1231 --- aider/io.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/aider/io.py b/aider/io.py index 1ac8d861b..2f1671c04 100644 --- a/aider/io.py +++ b/aider/io.py @@ -545,5 +545,12 @@ class InputOutput: if not text.endswith("\n"): text += "\n" if self.chat_history_file is not None: - with self.chat_history_file.open("a", encoding=self.encoding) as f: - f.write(text) + try: + with self.chat_history_file.open("a", encoding=self.encoding) as f: + f.write(text) + except PermissionError: + self.tool_error( + f"Warning: Unable to write to chat history file {self.chat_history_file}." + " Permission denied." + ) + self.chat_history_file = None # Disable further attempts to write