diff --git a/src/Box.php b/src/Box.php index d79509ed..90d45ce2 100644 --- a/src/Box.php +++ b/src/Box.php @@ -165,9 +165,14 @@ public function endBuffering(?callable $dumpAutoload): void $this->phar->buildFromDirectory($tmp); } } finally { - FS::remove($tmp); - // Must happen _after_ the remove as the latter has higher priority. - chdir($cwd); + if (PHP_OS_FAMILY === 'Windows') { + chdir($cwd); + FS::remove($tmp); + } else { + FS::remove($tmp); + // Must happen _after_ the remove as the latter has higher priority. + chdir($cwd); + } } $this->buffering = false;