From 7258023040d8604884560da02cfb6b5adb92c371 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 1 Dec 2023 18:52:45 +0100 Subject: [PATCH] Throw a more descriptive exception when the binary was not created When the build command fails and a binary was not created, this results in an error like `rename(app.phar, builds/app): the system cannot find the file specified `. This is not very descriptive to the actual issue, so this PR adds a check to thrown an exception if the file was not created. This will make debugging easier. See https://github.com/laravel-zero/laravel-zero/issues/461 --- src/Commands/BuildCommand.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Commands/BuildCommand.php b/src/Commands/BuildCommand.php index 7443367c..9acbac61 100644 --- a/src/Commands/BuildCommand.php +++ b/src/Commands/BuildCommand.php @@ -161,6 +161,10 @@ private function compile(string $name): BuildCommand $this->task(' 2. Compile into a single file'); $this->output->newLine(); + + if (! File::exists($this->app->basePath($this->getBinary()) . '.phar')) { + throw new \RuntimeException('Failed to compile the application.'); + } File::move($this->app->basePath($this->getBinary()).'.phar', $this->app->buildsPath($name));