clockwork: Seems to break Laravel even with APP_DEBUG false when index file is not writeable
first I got a laravel translator error because the translator class could not be loaded necessary for the 500 error blade page. the real error behind it is:
ocal.ERROR: unhandled exception. {"exceptionMessage":"Path \"/var/www/html/storage/clockwork/index\" is not writable.","stack":"#0 /var/www/html/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel
/ClockworkSupport.php(216): Clockwork\\Storage\\FileStorage->__construct()
php | #1 /var/www/html/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkServiceProvider.php(82): Clockwork\\Support\\Laravel\\ClockworkSupport->makeStorage()
php | #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(826): Clockwork\\Support\\Laravel\\ClockworkServiceProvider->Clockwork\\Support\\Laravel\\{closure}()
php | #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(712): Illuminate\\Container\\Container->build()
php | #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\\Container\\Container->resolve()
php | #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\\Foundation\\Application->resolve()
php | #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\\Container\\Container->make()
php | #7 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(1354): Illuminate\\Foundation\\Application->make()
php | #8 /var/www/html/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkServiceProvider.php(70): Illuminate\\Container\\Container->offsetGet()
php | #9 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(826): Clockwork\\Support\\Laravel\\ClockworkServiceProvider->Clockwork\\Support\\Laravel\\{closure}()
php | #10 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(712): Illuminate\\Container\\Container->build()
php | #11 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\\Container\\Container->resolve()
php | #12 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\\Foundation\\Application->resolve()
php | #13 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\\Container\\Container->make()
php | #14 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(1354): Illuminate\\Foundation\\Application->make()
php | #15 /var/www/html/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkSupport.php(448): Illuminate\\Container\\Container->offsetGet()
php | #16 /var/www/html/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkServiceProvider.php(48): Clockwork\\Support\\Laravel\\ClockworkSupport->configureShouldCollect()
php | #17 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(627): Clockwork\\Support\\Laravel\\ClockworkServiceProvider->register()
php | #18 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(75): Illuminate\\Foundation\\Application->register()
php | #19 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(604): Illuminate\\Foundation\\ProviderRepository->load()
php | #20 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\\Foundation\\Application->registerConfiguredProviders()
php | #21 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(230): Illuminate\\Foundation\\Bootstrap\\RegisterProviders->bootstrap()
php | #22 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(152): Illuminate\\Foundation\\Application->bootstrapWith()
php | #23 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(136): Illuminate\\Foundation\\Http\\Kernel->bootstrap()
php | #24 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
php | #25 /var/www/html/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle()
php | #26 {main}","exCode":0}
i would expect actually if clock work is disabled all this stuff wouldn’t happen either?
here is where it tries to read/write the index file. maybe this couldnt shouldnt happen already?
public function configureShouldCollect()
{
$this->app['clockwork']
}
Solution
adding
if (! $this->app['clockwork.support']->isEnabled()) return;
before:
$this->app->make('clockwork.request'); // instantiate the request to have id and time available as early as possible
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 20 (7 by maintainers)
The solution I’m using to ensure Clockwork isn’t loaded outside of local is similar to the local only installation of Telescope
AppServiceProvider:
composer.json:
This behavior is finally changed in Clockwork 5.2, closing them 2020 issues, woo.
I’m planning to tag a new release later this week.
To disable clockwork completely in laravel (and prevent permission-problems for instance), add this as a first line in the
boot()
andregister()
methods in the ClockworkServiceProvider:In production yes. In our case issue was with staging environment, where we kind of needed
dev
dependencies for testing related stuff. So theAppServiceProvider
workaround helped.For some teams this is the solution, for some it’s not (worked for us). By the way, we didn’t have that issue until we upgraded to
v5.1.5
. Old version wasv.4.1.7
IIRC. Behaviour has changed somewhere in between. I believe Clockwork simply should not try to createindex
file if it’s disabled in config. No matter environment and/or debug mode.