Open alfhh opened 3 months ago
Just to check if it's a Box issue, does it build if you run:
vendor/laravel-zero/framework/bin/box compile --config box.json
You should end up with a file called movie-cli.phar
in the root directory.
Can also add a --debug
option if it doesn't work, to get some further information.
Also, could you provide some information on your setup? Which OS and PHP version are you using?
Thanks for the reply @owenvoke.
Still failing and phar file is not created, but I got a different error message:
Box version 4.6.2@29c3585 2024-04-23 19:35:41 UTC
// Loading the configuration file "box.json".
[ERROR] The configuration file is invalid.
In Assert.php line 1012:
[_HumbugBoxc5dcacdc09f0\Webmozart\Assert\InvalidArgumentException]
The file "/Users/ahinojosa/workspace/movie-cli/builds/movie-cli" does not exist.
Is weird to see this error since my box.json
file is present.
Project structure:
Error:
Full Stacktrace:
vendor/laravel-zero/framework/bin/box compile --config box.json --debug
[debug] Changed the memory limit from "128MB" to "512M"
[debug] Checking BOX_ALLOW_XDEBUG
[debug] phar.readonly is enabled
[debug] The Xdebug extension is not loaded
[debug] Configured `phar.readonly=0`
[debug] Process restarting (BOX_ALLOW_XDEBUG=internal||1|*|*)
[debug] Running: [/usr/local/Cellar/php/8.3.7/bin/php, vendor/laravel-zero/framework/bin/box, compile, --config, box.json, --debug]
[debug] Current memory limit: "512MB"
[debug] Checking BOX_ALLOW_XDEBUG
[debug] Restarted (127 ms). The Xdebug extension is not loaded
____
/ __ )____ _ __
/ __ / __ \| |/_/
/ /_/ / /_/ /> <
/_____/\____/_/|_|
Box version 4.6.2@29c3585 2024-04-23 19:35:41 UTC
// Loading the configuration file "box.json".
[ERROR] The configuration file is invalid.
In Assert.php line 1012:
[_HumbugBoxc5dcacdc09f0\Webmozart\Assert\InvalidArgumentException]
The file "/Users/ahinojosa/workspace/movie-cli/builds/movie-cli" does not exist.
Exception trace:
at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/vendor/webmozart/assert/src/Assert.php:1012
_HumbugBoxc5dcacdc09f0\Webmozart\Assert\Assert::reportInvalidArgument() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/vendor/webmozart/assert/src/Assert.php:691
_HumbugBoxc5dcacdc09f0\Webmozart\Assert\Assert::fileExists() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/vendor/webmozart/assert/src/Assert.php:696
_HumbugBoxc5dcacdc09f0\Webmozart\Assert\Assert::file() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/src/Configuration/Configuration.php:786
_HumbugBoxc5dcacdc09f0\KevinGH\Box\Configuration\Configuration::retrieveMainScriptPath() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/src/Configuration/Configuration.php:147
_HumbugBoxc5dcacdc09f0\KevinGH\Box\Configuration\Configuration::create() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/src/Configuration/ConfigurationLoader.php:21
_HumbugBoxc5dcacdc09f0\KevinGH\Box\Configuration\ConfigurationLoader->loadFile() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/src/Console/ConfigurationLoader.php:22
_HumbugBoxc5dcacdc09f0\KevinGH\Box\Console\ConfigurationLoader::getConfig() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/src/Console/Command/ConfigOption.php:22
_HumbugBoxc5dcacdc09f0\KevinGH\Box\Console\Command\ConfigOption::getConfig() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/src/Console/Command/CompileCommand.php:115
_HumbugBoxc5dcacdc09f0\KevinGH\Box\Console\Command\CompileCommand->execute() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/vendor/fidry/console/src/Bridge/Command/SymfonyCommand.php:69
_HumbugBoxc5dcacdc09f0\Fidry\Console\Bridge\Command\SymfonyCommand->execute() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/vendor/symfony/console/Command/Command.php:151
_HumbugBoxc5dcacdc09f0\Symfony\Component\Console\Command\Command->run() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/vendor/symfony/console/Application.php:690
_HumbugBoxc5dcacdc09f0\Symfony\Component\Console\Application->doRunCommand() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/vendor/symfony/console/Application.php:230
_HumbugBoxc5dcacdc09f0\Symfony\Component\Console\Application->doRun() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/vendor/symfony/console/Application.php:123
_HumbugBoxc5dcacdc09f0\Symfony\Component\Console\Application->run() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/vendor/fidry/console/src/Application/ApplicationRunner.php:39
_HumbugBoxc5dcacdc09f0\Fidry\Console\Application\ApplicationRunner->run() at phar:///Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box/bin/box:47
require() at /Users/ahinojosa/workspace/movie-cli/vendor/laravel-zero/framework/bin/box:19
I'm having exactly the same issue with:
laravel-zero/foundation v11.5.0 laravel-zero/framework v11.0.1 PHP 8.3.7
Sorry, I completely forgot to get back to this. I was able to replicate it locally.
Unfortunately, I don't have time at the moment to investigate it further though. I'm pretty sure it's something to do with the current working directory that Box runs in (possibly due to the binary being re-run).
No worries. I downgraded my project back to laravel-zero 10 and build seems to work now fine. I might try to debug and create a PR to resolve this issue next weekend if someone else haven't had time to fix it before that 🙃
I also ran into the same issue. Running vendor/laravel-zero/framework/bin/box compile --config box.json
works successfully. I figured therefore it maybe the box command is being run from the wrong path.
As a temporary workaround, I created a symlink in the CWD with which worked for me
ln vendor/laravel-zero/framework/bin/box box
@owenvoke the issue occurs in BuildCommand
file in compile
method on line 152
.
laravel-zero/framework/src/Commands/BuildCommand.php
on line 152
foreach (tap($process)->start() as $type => $data) {
...
In fact, the $process
returns and exception because it can't find the ./box
path.
I dug deeper and found out that the Process->start
method in file Process.php
uses @proc_open
and this one, even if it uses the $this->cwd
attribute, doesn't find the ./box
path.
symfony/process/Process.php
on line 363
:
$process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
$process
is false
.
It works if you add this line before @proc_open
:
$commandline[0] = "$this->cwd/$commandline[0]";
$process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
So it seems that @proc_open
doesn't take $this->cwd
into account. I don't know why.
And this is probably linked with PHP8.3 and this link could possibly be the reason.
Thanks for all the comments on this thread!
I was able to unblock my build by using this workaround, thank you @SamuelMwangiW
I also ran into the same issue. Running
vendor/laravel-zero/framework/bin/box compile --config box.json
works successfully. I figured therefore it maybe the box command is being run from the wrong path.As a temporary workaround, I created a symlink in the CWD with which worked for me
ln vendor/laravel-zero/framework/bin/box box
Hello!!
I'm currently facing an issue while trying to build the a
phar
.This is the error that I'm getting:
I faced this issue with an existing project but I also face this problem if I start a brand new project following the installation instructions.
Things that I have tried:
box.json
file exists and is present on the projectphp
) torequire-dev
My guess is that I'm missing something in the setup piece, but I followed the available documentation, if there is a gap in the installation guide I'm happy to raise a PR once I get this to work.
Any guidance? Thanks!!1