From 6dc0b8d8536c909ab43bf4bf508c2b3b2cf79f3f Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 29 Oct 2024 13:14:37 -0700 Subject: [PATCH] fix: use absolute paths for read-only files outside repo root --- aider/commands.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 83f741f34..3a270059d 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -1285,8 +1285,12 @@ class Commands: # Write commands to add read-only files for fname in sorted(self.coder.abs_read_only_fnames): - rel_fname = self.coder.get_rel_fname(fname) - f.write(f"/read-only {rel_fname}\n") + # Use absolute path for files outside repo root, relative path for files inside + if Path(fname).is_relative_to(self.coder.root): + rel_fname = self.coder.get_rel_fname(fname) + f.write(f"/read-only {rel_fname}\n") + else: + f.write(f"/read-only {fname}\n") self.io.tool_output(f"Saved commands to {args.strip()}") except Exception as e: