From bf167a3126245998a29bcb6dd0c2e3ca40a5edb5 Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Mon, 7 Jul 2025 12:23:55 -0400 Subject: [PATCH] GP-5810: Improving CWD removal from sys.path --- .../Features/PyGhidra/src/main/py/src/pyghidra/launcher.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py index 1b8ed13bfc..fd5bc6ce8d 100644 --- a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py +++ b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py @@ -431,7 +431,11 @@ class PyGhidraLauncher: # Remove CWD from sys.path so we don't try to import from unintentional directories # (i.e, an unrelated "ghidra" directory the user may have created) - sys.path.remove(os.getcwd()) + try: + sys.path.remove(os.getcwd()) + except ValueError: + # CWD wasn't present on sys.path + pass # Install hooks into python importlib sys.meta_path.append(_PyGhidraImportLoader())