swooletw / hyperf-packages

About Laravel Hyperf is a Laravel-style skeleton based on Hyperf framework designed for Laravel artisans.
https://laravel-hyperf.com
MIT License
11 stars 3 forks source link

mkdir(): Invalid path in ./vendor/hyperf/view-engine/src/Factory/FinderFactory.php:32 #34

Closed harryqt closed 1 month ago

harryqt commented 1 month ago

OS

MacOS 14

PHP Version

8.3.11

Swoole Extension Version

5.1.4

Description

~/Projects/example-laravel-hyperf- php hyperf serve                                                                        ✔ 
[INFO] Worker#4 started.
[INFO] Worker#0 started.
[INFO] Worker#1 started.
[INFO] Worker#2 started.
[INFO] HTTP Server listening at 0.0.0.0:9501
[INFO] Worker#5 started.
[INFO] Worker#6 started.
[INFO] Worker#3 started.
[INFO] Worker#7 started.
[CRITICAL] ErrorException: mkdir(): Invalid path in /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/view-engine/src/Factory/FinderFactory.php:32
Stack trace:
#0 [internal function]: Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler::Hyperf\ExceptionHandler\Listener\{closure}(2, 'mkdir(): Invali...', '/Users/harry/Pr...', 32)
#1 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/view-engine/src/Factory/FinderFactory.php(32): mkdir('', 493, true)
#2 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/FactoryResolver.php(46): Hyperf\ViewEngine\Factory\FinderFactory->__invoke(Object(SwooleTW\Hyperf\Foundation\Application), Array)
#3 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ResolverDispatcher.php(51): Hyperf\Di\Resolver\FactoryResolver->resolve(Object(Hyperf\Di\Definition\FactoryDefinition), Array)
#4 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/DepthGuard.php(68): Hyperf\Di\Resolver\ResolverDispatcher->Hyperf\Di\Resolver\{closure}()
#5 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ResolverDispatcher.php(49): Hyperf\Di\Resolver\DepthGuard->call('Hyperf\\ViewEngi...', Object(Closure))
#6 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Container.php(161): Hyperf\Di\Resolver\ResolverDispatcher->resolve(Object(Hyperf\Di\Definition\FactoryDefinition), Array)
#7 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Container.php(62): Hyperf\Di\Container->resolveDefinition(Object(Hyperf\Di\Definition\FactoryDefinition), Array)
#8 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/container/src/Container.php(120): Hyperf\Di\Container->make('Hyperf\\ViewEngi...', Array)
#9 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Container.php(103): SwooleTW\Hyperf\Container\Container->make('Hyperf\\ViewEngi...')
#10 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/container/src/Container.php(145): Hyperf\Di\Container->get('Hyperf\\ViewEngi...')
#11 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Definition/Reference.php(64): SwooleTW\Hyperf\Container\Container->get('Hyperf\\ViewEngi...')
#12 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ResolverDispatcher.php(44): Hyperf\Di\Definition\Reference->resolve(Object(SwooleTW\Hyperf\Foundation\Application))
#13 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ParameterResolver.php(64): Hyperf\Di\Resolver\ResolverDispatcher->resolve(Object(Hyperf\Di\Definition\Reference))
#14 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ObjectResolver.php(84): Hyperf\Di\Resolver\ParameterResolver->resolveParameters(Object(Hyperf\Di\Definition\MethodInjection), Object(ReflectionMethod), Array)
#15 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ObjectResolver.php(52): Hyperf\Di\Resolver\ObjectResolver->createInstance(Object(Hyperf\Di\Definition\ObjectDefinition), Array)
#16 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ResolverDispatcher.php(51): Hyperf\Di\Resolver\ObjectResolver->resolve(Object(Hyperf\Di\Definition\ObjectDefinition), Array)
#17 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/DepthGuard.php(68): Hyperf\Di\Resolver\ResolverDispatcher->Hyperf\Di\Resolver\{closure}()
#18 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ResolverDispatcher.php(49): Hyperf\Di\Resolver\DepthGuard->call('Hyperf\\ViewEngi...', Object(Closure))
#19 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Container.php(161): Hyperf\Di\Resolver\ResolverDispatcher->resolve(Object(Hyperf\Di\Definition\ObjectDefinition), Array)
#20 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Container.php(62): Hyperf\Di\Container->resolveDefinition(Object(Hyperf\Di\Definition\ObjectDefinition), Array)
#21 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/container/src/Container.php(120): Hyperf\Di\Container->make('Hyperf\\ViewEngi...', Array)
#22 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Container.php(103): SwooleTW\Hyperf\Container\Container->make('Hyperf\\ViewEngi...')
#23 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/container/src/Container.php(145): Hyperf\Di\Container->get('Hyperf\\ViewEngi...')
#24 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/support/src/Facades/Facade.php(175): SwooleTW\Hyperf\Container\Container->get('Hyperf\\ViewEngi...')
#25 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/support/src/Facades/Facade.php(158): SwooleTW\Hyperf\Support\Facades\Facade::resolveFacadeInstance('Hyperf\\ViewEngi...')
#26 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/support/src/Facades/Facade.php(144): SwooleTW\Hyperf\Support\Facades\Facade::getFacadeRoot()
#27 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/foundation/src/Exceptions/RegisterErrorViewPaths.php(16): SwooleTW\Hyperf\Support\Facades\Facade::__callStatic('replaceNamespac...', Array)
#28 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/foundation/src/Exceptions/Handler.php(794): SwooleTW\Hyperf\Foundation\Exceptions\RegisterErrorViewPaths->__invoke()
#29 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/foundation/src/Exceptions/Handler.php(139): SwooleTW\Hyperf\Foundation\Exceptions\Handler->registerErrorViewPaths()
#30 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ObjectResolver.php(85): SwooleTW\Hyperf\Foundation\Exceptions\Handler->__construct(Object(SwooleTW\Hyperf\Foundation\Application))
#31 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ObjectResolver.php(52): Hyperf\Di\Resolver\ObjectResolver->createInstance(Object(Hyperf\Di\Definition\ObjectDefinition), Array)
#32 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ResolverDispatcher.php(51): Hyperf\Di\Resolver\ObjectResolver->resolve(Object(Hyperf\Di\Definition\ObjectDefinition), Array)
#33 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/DepthGuard.php(68): Hyperf\Di\Resolver\ResolverDispatcher->Hyperf\Di\Resolver\{closure}()
#34 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Resolver/ResolverDispatcher.php(49): Hyperf\Di\Resolver\DepthGuard->call('App\\Exceptions\\...', Object(Closure))
#35 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Container.php(161): Hyperf\Di\Resolver\ResolverDispatcher->resolve(Object(Hyperf\Di\Definition\ObjectDefinition), Array)
#36 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Container.php(62): Hyperf\Di\Container->resolveDefinition(Object(Hyperf\Di\Definition\ObjectDefinition), Array)
#37 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/container/src/Container.php(120): Hyperf\Di\Container->make('App\\Exceptions\\...', Array)
#38 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/di/src/Container.php(103): SwooleTW\Hyperf\Container\Container->make('App\\Exceptions\\...')
#39 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/container/src/Container.php(145): Hyperf\Di\Container->get('App\\Exceptions\\...')
#40 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/exception-handler/src/ExceptionHandlerDispatcher.php(40): SwooleTW\Hyperf\Container\Container->get('App\\Exceptions\\...')
#41 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/foundation/src/Http/Kernel.php(113): Hyperf\ExceptionHandler\ExceptionHandlerDispatcher->dispatch(Object(ErrorException), Array)
#42 /Users/harry/Projects/example-laravel-hyperf/vendor/hyperf/support/src/SafeCaller.php(30): SwooleTW\Hyperf\Foundation\Http\Kernel->SwooleTW\Hyperf\Foundation\Http\{closure}()
#43 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/foundation/src/Http/Kernel.php(112): Hyperf\Support\SafeCaller->call(Object(Closure), Object(Closure))
#44 /Users/harry/Projects/example-laravel-hyperf/vendor/swooletw/hyperf-packages/src/foundation/src/Http/Kernel.php(56): SwooleTW\Hyperf\Foundation\Http\Kernel->getResponseForException(Object(ErrorException))
#45 [internal function]: SwooleTW\Hyperf\Foundation\Http\Kernel->onRequest(Object(Swoole\Http\Request), Object(Swoole\Http\Response))
#46 {main}

Steps To Reproduce

composer create-project swooletw/laravel-hyperf example-laravel-hyperf dev-master
php hyperf serve

Then open: http://localhost:9501

albertcht commented 1 month ago

Hi @harryqt ,

Can you please try to run with Swoole 5.1.2 or 5.1.3? One of my team members also reported this issue few days ago. And I'm verifying if it only happens on Swoole 5.1.4.

storyn26383 commented 1 month ago

Hi @harryqt, I encountered the same issue as you. After some research, I discovered that Swoole's coroutine was causing the issue. There is a simple code that reproduces the issue:

Swoole\Runtime::enableCoroutine(true);
var_dump(scandir(__DIR__));

You'll notice that when the coroutine is enabled, scandir returns an empty array, which prevents the framework from finding the config files, thus causing this error. This morning, I upgraded my Mac to version 15 and reinstalled Swoole, which resolved the issue.

harryqt commented 1 month ago

What’s your Swoole and Php version?

storyn26383 commented 1 month ago

What’s your Swoole and Php version?

Same as you, PHP 8.3.11, Swoole 5.1.4. I installed them via Homebrew.

brew install shivammathur/php/php
brew install shivammathur/extensions/swoole@8.3
harryqt commented 1 month ago

Reinstall of Swoole solved the issue. 🤷

brew reinstall swoole@8.3