clockwork
clockwork copied to clipboard
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
Hey, I agree this is a bit of an unexpected behavior. Not sure about the solution yet, will need to investigate more.
The solution I'm using to ensure Clockwork isn't loaded outside of local is similar to the local only installation of Telescope
AppServiceProvider:
public function register()
{
if ($this->app->environment('local') && config('clockwork.enable')) {
$this->app->register(\Clockwork\Support\Laravel\ClockworkServiceProvider::class);
}
}
composer.json:
"extra": {
"laravel": {
"dont-discover": [
"itsgoingd/clockwork"
]
}
},
@itsgoingd Should we use @petecoop approach to avoid this?
I see no issues with the conditional registration approach described above. This will also be resolved at the Clockwork side at some point.
The solution I'm using to ensure Clockwork isn't loaded outside of local is similar to the local only installation of Telescope
AppServiceProvider:
public function register() { if ($this->app->environment('local') && config('clockwork.enable')) { $this->app->register(\Clockwork\Support\Laravel\ClockworkServiceProvider::class); } }
composer.json:
"extra": { "laravel": { "dont-discover": [ "itsgoingd/clockwork" ] } },
Maybe I've misunderstood something, but would installing Clockwork as a dev dependency and removing it in production with composer --no-dev
solve this issue?
Sure, installing as a dev dependency is also a good workaround, will think about recommending that in the future.
Sure, installing as a dev dependency is also a good workaround, will think about recommending that in the future.
But what I'm really interested is whether this is a solution to the problem at all. I'm running into the same 500 error - /storage/clockwork/index\ is not writable
, and maybe I'm misunderstanding Clockwork - but isn't part of its design to run on the server itself? I've seen it described in places as a server-side tool to analyse sites in production. Even the documentation for this very repository says it:
contains the server-side component of Clockwork
If this is the case then either disabling it in non-local environments isn't a solution at all, or I'm misunderstanding something.
Maybe I've misunderstood something, but would installing Clockwork as a dev dependency and removing it in production with composer --no-dev solve this issue?
In production yes. In our case issue was with staging environment, where we kind of needed dev
dependencies for testing related stuff. So the AppServiceProvider
workaround helped.
If this is the case then either disabling it in non-local environments isn't a solution at all, or I'm misunderstanding something.
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 was v.4.1.7
IIRC. Behaviour has changed somewhere in between. I believe Clockwork simply should not try to create index
file if it's disabled in config. No matter environment and/or debug mode.
The solution I'm using to ensure Clockwork isn't loaded outside of local is similar to the local only installation of Telescope
AppServiceProvider:
public function register() { if ($this->app->environment('local') && config('clockwork.enable')) { $this->app->register(\Clockwork\Support\Laravel\ClockworkServiceProvider::class); } }
composer.json:
"extra": { "laravel": { "dont-discover": [ "itsgoingd/clockwork" ] } },
I'm experiencing the same issue and for some reason this solution does not work in our situation. Anybody else has an updated solution? Maybe this could be added to the package to avoid writing the index file when clockwork should not be enabled?
Hey, I would suggest explicitly disabling Clockwork by setting CLOCKWORK_ENABLE=false
in your env file.
I need to disabled clockwork in an specific script and then, enable it again!!
Even in disabled mode clockwork creates the temporary directories if used within laravel and this should not be the done. Running a test (which uses another user than the webserver), always gives me permission issues on the /tmp/clockwork
-folder.
To disable clockwork completely in laravel (and prevent permission-problems for instance), add this as a first line in the boot()
and register()
methods in the ClockworkServiceProvider:
if (!config('clockwork.enable', false)) return;
Same issue v5.1
also having this, can this be fixed @itsgoingd ?
Hey, I've moved the path checks to the store method in dev-master
, this should fix the issue.
Hey, I've moved the path checks to the store method in
dev-master
, this should fix the issue.
Thanks @itsgoingd. Any chance of a minor release?
I'm planning to tag a new release later this week.
Same problem with disabled clockwork. Hope release will be soon.
This behavior is finally changed in Clockwork 5.2, closing them 2020 issues, woo.