关于使用 box-project/box 打包项目为 phar 后遇到的 crc32 mismatch on file… 的问题以及解决方案

之前在弄 Laravel Zero + Gateway Worker 的。Laravel Zero 有个开箱即用的打包单文件运行功能。

但是遇到以下错误。

ErrorException: include(phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/composer/../workerman/workerman/Connection/AsyncTcpConnection.php): Failed to open stream: phar error: internal corruption of phar "/Users/ivampiresp/Projects/forbiddenforest/builds/application" (crc32 mismatch on file "vendor/workerman/workerman/Connection/AsyncTcpConnection.php") in phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/.box/vendor/composer/ClassLoader.php:571
Stack trace:
#0 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(254): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'include(phar://...', 'phar:///Users/i...', 571)
#1 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/.box/vendor/composer/ClassLoader.php(571): Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}(2, 'include(phar://...', 'phar:///Users/i...', 571)
#2 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/.box/vendor/composer/ClassLoader.php(571): include('phar:///Users/i...')
#3 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/.box/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('phar:///Users/i...')
#4 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/workerman/gateway-worker/src/BusinessWorker.php(278): Composer\Autoload\ClassLoader->loadClass('Workerman\\Conne...')
#5 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/workerman/gateway-worker/src/BusinessWorker.php(205): GatewayWorker\BusinessWorker->connectToRegister()
#6 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/workerman/workerman/Worker.php(2488): GatewayWorker\BusinessWorker->onWorkerStart(Object(GatewayWorker\BusinessWorker))
#7 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/workerman/gateway-worker/src/BusinessWorker.php(184): Workerman\Worker->run()
#8 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/workerman/workerman/Worker.php(1627): GatewayWorker\BusinessWorker->run()
#9 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/workerman/workerman/Worker.php(1423): Workerman\Worker::forkOneWorkerForLinux(Object(GatewayWorker\BusinessWorker))
#10 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/workerman/workerman/Worker.php(1397): Workerman\Worker::forkWorkersForLinux()
#11 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/workerman/workerman/Worker.php(560): Workerman\Worker::forkWorkers()
#12 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/app/Commands/WorkerCommand.php(58): Workerman\Worker::runAll()
#13 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/app/Commands/WorkerCommand.php(43): App\Commands\WorkerCommand->startBusinessWorker()
#14 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/illuminate/container/BoundMethod.php(36): App\Commands\WorkerCommand->handle()
#15 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/illuminate/container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#16 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/illuminate/container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#17 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/illuminate/container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod(Object(LaravelZero\Framework\Application), Array, Object(Closure))
#18 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/illuminate/container/Container.php(662): Illuminate\Container\BoundMethod::call(Object(LaravelZero\Framework\Application), Array, Array, NULL)
#19 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/illuminate/console/Command.php(208): Illuminate\Container\Container->call(Array)
#20 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/symfony/console/Command/Command.php(312): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#21 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/illuminate/console/Command.php(177): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#22 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/symfony/console/Application.php(1040): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/symfony/console/Application.php(314): Symfony\Component\Console\Application->doRunCommand(Object(App\Commands\WorkerCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/symfony/console/Application.php(168): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Console/Kernel.php(200): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/vendor/laravel-zero/framework/src/Kernel.php(96): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 phar:///Users/ivampiresp/Projects/forbiddenforest/builds/application/application(34): LaravelZero\Framework\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /Users/ivampiresp/Projects/forbiddenforest/builds/application(14): require('phar:///Users/i...')
#29 {main}
worker[BusinessWorker:22648] exit with status 64000
^CWorkerman[application] stopping ...
Workerman[application] has been stopped

定位到错误是 crc32 mismatch on file。
现在发现错误了,让我们开始解决错误吧。

不过,依靠搜索引擎,我发现了个在 SMProxy 下的 Issue

解决方案

我们只需要到 box.json 中,将 compression 的值改成 NONE 即可。

现在再次打包并运行 Workerman,成功。

评论

  1. 阿龙
    Windows Chrome 114.0.0.0
    1 年前
    2023-7-04 23:05:03

    (╯‵□′)╯︵┴─┴

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇