diff --git a/src/serena/util/file_system.py b/src/serena/util/file_system.py index 3784a17a..d7d9f956 100644 --- a/src/serena/util/file_system.py +++ b/src/serena/util/file_system.py @@ -165,10 +165,14 @@ class GitignoreParser: def scan(abs_path: str | None) -> Iterator[str]: for entry in os.scandir(abs_path): - if entry.is_dir(follow_symlinks=follow_symlinks): - queue.append(entry.path) - elif entry.is_file(follow_symlinks=follow_symlinks) and entry.name == ".gitignore": - yield entry.path + try: + if entry.is_dir(follow_symlinks=follow_symlinks): + queue.append(entry.path) + elif entry.is_file(follow_symlinks=follow_symlinks) and entry.name == ".gitignore": + yield entry.path + except PermissionError as ex: + log.debug(f"Skipping entry due to permission error: {entry.path}", exc_info=ex) + continue while queue: next_abs_path = queue.pop(0)