From 2fe374ea7c38a405c2e0d3db6b9792b82e384cf9 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Thu, 16 Jul 2026 19:56:39 +0100 Subject: [PATCH] 554: do not attempt to use sudo on Windows --- src/File/Sudo.php | 5 +++++ test/unit/File/SudoTest.php | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/unit/File/SudoTest.php diff --git a/src/File/Sudo.php b/src/File/Sudo.php index 56f61c24..92898132 100644 --- a/src/File/Sudo.php +++ b/src/File/Sudo.php @@ -4,6 +4,7 @@ namespace Php\Pie\File; +use Composer\Util\Platform as ComposerPlatform; use Php\Pie\Platform; use Php\Pie\Platform\TargetPlatform; use Symfony\Component\Process\ExecutableFinder; @@ -23,6 +24,10 @@ final class Sudo */ public static function find(): string { + if (ComposerPlatform::isWindows()) { + throw SudoNotFoundOnSystem::new(); + } + if (! is_string(self::$memoizedSudo)) { $sudo = (new ExecutableFinder())->find('sudo'); diff --git a/test/unit/File/SudoTest.php b/test/unit/File/SudoTest.php new file mode 100644 index 00000000..4c637c75 --- /dev/null +++ b/test/unit/File/SudoTest.php @@ -0,0 +1,27 @@ +expectException(SudoNotFoundOnSystem::class); + Sudo::find(); + } +}