Skip to content

Commit 47ed3d9

Browse files
committed
Fix crash in collect-copyright
If there happens to be a directory called 'brew' in $PATH, on Linux, collect-copyright will fail with a PermissionError, not running the fallback code. This happened to a contributor on WSL2. When a PermissionError happens, assume the command doesn't exist.
1 parent a58d35f commit 47ed3d9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/collect-copyright

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,19 @@ def detect_system_package_manager(
189189
).rstrip("\n")
190190
if any(is_path_relative(root_path=brew_prefix, sub_path=f) for f in files):
191191
return Homebrew(brew_prefix=brew_prefix)
192-
except (subprocess.CalledProcessError, FileNotFoundError):
192+
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
193193
pass
194194

195195
try:
196196
subprocess.check_output(["rpm", "--query", "glibc"])
197197
return RedHat()
198-
except (subprocess.CalledProcessError, FileNotFoundError):
198+
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
199199
pass
200200

201201
try:
202202
subprocess.check_output(["dpkg-query", "--list", "libc6"])
203203
return Debian()
204-
except (subprocess.CalledProcessError, FileNotFoundError):
204+
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
205205
pass
206206

207207
return None

0 commit comments

Comments
 (0)