diff --git a/skills/last30days/scripts/lib/xurl_x.py b/skills/last30days/scripts/lib/xurl_x.py index 994b58c..c2a60ef 100644 --- a/skills/last30days/scripts/lib/xurl_x.py +++ b/skills/last30days/scripts/lib/xurl_x.py @@ -46,9 +46,10 @@ def is_available() -> bool: timeout=10, ) return result.returncode == 0 and '"username"' in result.stdout - except FileNotFoundError: - return False - except subprocess.TimeoutExpired: + except (OSError, subprocess.TimeoutExpired): + # OSError covers FileNotFoundError (no xurl on PATH) and + # PermissionError (a non-executable match on PATH, e.g. WSL's + # /mnt/c/.../WindowsApps shim returning EACCES on exec). return False diff --git a/tests/test_xurl_x.py b/tests/test_xurl_x.py index 14bce72..7f79e09 100644 --- a/tests/test_xurl_x.py +++ b/tests/test_xurl_x.py @@ -44,6 +44,13 @@ class TestIsAvailable(unittest.TestCase): with mock.patch("subprocess.run", side_effect=FileNotFoundError): self.assertFalse(xurl_x.is_available()) + def test_returns_false_on_permission_error(self): + # WSL hits this when a Windows-mounted PATH entry points at an + # exec-blocked shim (e.g. WindowsApps), which raises PermissionError + # before any other PATH candidate is tried. + with mock.patch("subprocess.run", side_effect=PermissionError(13, "Permission denied", "xurl")): + self.assertFalse(xurl_x.is_available()) + def test_returns_false_on_timeout(self): import subprocess with mock.patch("subprocess.run", side_effect=subprocess.TimeoutExpired("xurl", 10)):