From 94a6d3bc7e166c2c224e6c47e2c75c50ec8630e8 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 11 Nov 2024 09:55:23 -0800 Subject: [PATCH] fix: Handle case when current working directory is inaccessible in git setup --- aider/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aider/main.py b/aider/main.py index cd25b2445..2d3b10086 100644 --- a/aider/main.py +++ b/aider/main.py @@ -90,7 +90,7 @@ def setup_git(git_root, io): try: cwd = Path.cwd() except OSError: - return None + cwd = None repo = None @@ -99,7 +99,9 @@ def setup_git(git_root, io): elif cwd == Path.home(): io.tool_warning("You should probably run aider in a directory, not your home dir.") return - elif io.confirm_ask("No git repo found, create one to track aider's changes (recommended)?"): + elif cwd and io.confirm_ask( + "No git repo found, create one to track aider's changes (recommended)?" + ): git_root = str(cwd.resolve()) repo = make_new_repo(git_root, io)