From e526d2890cc8d617fabc98f03964dcea57a4cfc6 Mon Sep 17 00:00:00 2001 From: fry69 <142489379+fry69@users.noreply.github.com> Date: Sun, 8 Sep 2024 12:47:07 +0200 Subject: [PATCH] fix: handle OSError when executing lint command --- aider/linter.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/aider/linter.py b/aider/linter.py index 9014c88909d..23e0112c74e 100644 --- a/aider/linter.py +++ b/aider/linter.py @@ -46,14 +46,18 @@ def run_cmd(self, cmd, rel_fname, code): cmd += " " + rel_fname cmd = cmd.split() - process = subprocess.Popen( - cmd, - cwd=self.root, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - encoding=self.encoding, - errors="replace", - ) + try: + process = subprocess.Popen( + cmd, + cwd=self.root, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + encoding=self.encoding, + errors="replace", + ) + except OSError as err: + print(f"Unable to execute lint command: {err}") + return stdout, _ = process.communicate() errors = stdout if process.returncode == 0: