Body: <p>I've been finding recently that our cron is often failing. Our host doesn't keep output from the cron processes in the logs, so it's hard to establish the differences between the times that it works and the times that it doesn't. Testing the command manually at the CLI at the moment though, I'm getting this error:</p>
  <pre><code>$ /usr/bin/php-7.3 /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/bin/cli.php -s civicrm.example.net -u cronuser -p password -e Job -a execute
  Fatal error: Uncaught Error: Class 'Civi\Api4\Event\Subscriber\SearchKitSubscriber' not found in /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/ext/search_kit/search_kit.php:14
  Stack trace:
  #0 /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/CRM/Utils/Hook.php(271): search_kit_civicrm_config(Object(CRM_Core_Config))
  #1 /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/CRM/Utils/Hook/DrupalBase.php(73): CRM_Utils_Hook-&gt;runHooks(Array, 'civicrm_config', 1, Object(CRM_Core_Config), NULL, NULL, NULL, NULL, NULL)
  #2 /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/Civi/Core/CiviEventDispatcher.php(248): CRM_Utils_Hook_DrupalBase-&gt;invokeViaUF(1, Object(CRM_Core_Config), NULL, NULL, NULL, NULL, NULL, 'civicrm_config')
  #3 /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php(214): Civi\Core\CiviEventDispatcher::delegateToUF(O in /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/ext/search_kit/search_kit.php on line 14
  </code></pre>
  <p>This is on Drupal 7.91 and CiviCRM 5.51.1, but it's been going on for a while.</p>
  <p><strong>Edit 26/7/2022:</strong> I've been trying to test the command with cv, but I think something with our host is preventing it from running. I'm fairly beginner with Linux though, so maybe I'm missing something. I followed the instructions at <a href="https://github.com/civicrm/cv" rel="nofollow noreferrer">https://github.com/civicrm/cv</a>. I can't use sudo, but it seemed to work fine without. I don't have access to <code>/usr/local/bin</code> though, so just installed in <code>~/</code>. Then when I try to run I see this:</p>
  <pre><code>$ ls cv -l
  -rwxr-xr-x 1 username gid 1768622 Jul 26 12:15 cv
  $ cv
  bash: cv: command not found
  </code></pre>
  <p><strong>Edit 2/8/2022:</strong> Trying to run from my Drupal root folder results in the following:</p>
  <pre><code>$ ~/cv list
  Fatal error: Class 'Phar' not found in /var/sites/c/civicrm.example.net/cv on line 10
  </code></pre>
  <p><strong>Edit 23/8/2022:</strong> Testing for Phar returns as follows:</p>
  <pre><code>$ php -i | grep phar
  Registered PHP Streams =&gt; https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar, sqlsrv, zip
  Phar-based phar archives =&gt; enabled
  Tar-based phar archives =&gt; enabled
  ZIP-based phar archives =&gt; enabled
  phar.cache_list =&gt; no value =&gt; no value
  phar.readonly =&gt; On =&gt; On
  phar.require_hash =&gt; On =&gt; On
  </code></pre>
  <p><strong>Edit 2/9/2022:</strong> Trying to establish if cv is using a different php isn't going very well:</p>
  <pre><code>$ which php
  bash: which: command not found
  $ /usr/bin/env which php
  /usr/bin/env: which: No such file or directory
  </code></pre>
  <p><strong>Edit 6/9/2022:</strong> PATH is as follows:</p>
  <pre><code>$ echo $PATH
  /usr/local/bin:/usr/bin
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-07-22T17:30:39.680Z
Comments.Text: If you run the same command with `cv` does it give the same error? `cv api --user=cronuser Job.execute` I'm wondering if bin/cli.php maybe doesn't "boot enough" for search kit.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-07-26T16:18:04.500Z
Comments.Text: @Demerit I've updated the post with the results. Maybe I've not installed it correctly, but I think maybe the host is blocking it somehow. I used to have Drush installed and it stopped working after an update the host did. That was last year some time though, long before this error, so I don't think the two are connected.
Comments.UserDisplayName: somnolentsurfer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-07-26T16:25:00.523Z
Comments.Text: Your home folder probably isn't in your path. Also it's easiest to run it from within the civi or drupal folder so it can figure out which site, so `cd /path/to/drupal`, then give the full path to cv e.g. `~/cv list`
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-02T14:11:57.173Z
Comments.Text: Huh. You have to specify full paths to execute a file in Linux? I'm even more of a beginner than I thought! Updated the question with the new error.
Comments.UserDisplayName: somnolentsurfer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-02T14:18:49.290Z
Comments.Text: No you don't but you had originally put cv in `~` which is unlikely to be in the PATH. Your new error suggests that php on that system does not include Phar, which is unusual but possible. If you run `php -i | grep phar` it should show some information about it if it's installed, otherwise I'd ask your host if php phar is enabled.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-23T16:35:33.923Z
Comments.Text: Apologies, have been away. Thanks for the help. I've updated with the output. There's a bunch of lines that say 'enabled', but I don't really know what I'm reading. Does that look like it's installed?
Comments.UserDisplayName: somnolentsurfer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-23T18:09:11.567Z
Comments.Text: Ok that does look enabled. I wonder if it's possible cv is using a different php. If you run `/usr/bin/env which php` which php does it say? And is that different from just `which php`?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-02T10:47:14.777Z
Comments.Text: Sorry, away again. Have updated with the result. Apparently I can't run which.
Comments.UserDisplayName: somnolentsurfer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-02T14:03:54.713Z
Comments.Text: That is bizarre. How about `echo $PATH` ? It's possible this is some kind of really locked down environment and CLI is meant for only really basic stuff. Back to the original problem, what method and how are you running cron? If you look in [ConfigAndLog](https://civicrm.stackexchange.com/questions/15931/where-are-the-configandlog-and-templates-c-directories) are there any errors that might seem related to your cron?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-06T10:35:12.320Z
Comments.Text: Added the PATH above. I'm using the cli.php method, with the command in the first code block above. There's a load of stuff in ConfigAndLog over the weekend, but I think that's related to [this new error](https://civicrm.stackexchange.com/questions/42565/the-website-encountered-an-unexpected-error-please-try-again-later-when-tryi). There's nothing consistent that appears over the last couple of months this has been going on. It does feel like at some point our host massively locked down what we're able to do. I've never had cv working, but drush used to work and doesn't any longer.
Comments.UserDisplayName: somnolentsurfer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-06T14:19:55.083Z
Comments.Text: At this point it's probably best to ask your host what kind of environment this is. The PATH looks ok but there's something off somewhere.
Comments.UserDisplayName: Demerit
Tags: <cron><searchkit><apiv4>
Title: Class 'Civi\Api4\Event\Subscriber\SearchKitSubscriber' not found
ThreadText: # Class 'Civi\Api4\Event\Subscriber\SearchKitSubscriber' not found
  
  (Asked by: username_0 on 2022-07-22)
  
  I've been finding recently that our cron is often failing. Our host doesn't keep output from the cron processes in the logs, so it's hard to establish the differences between the times that it works and the times that it doesn't. Testing the command manually at the CLI at the moment though, I'm getting this error:
  $ /usr/bin/php-7.3 /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/bin/cli.php -s civicrm.example.net -u cronuser -p password -e Job -a execute
  Fatal error: Uncaught Error: Class 'Civi\Api4\Event\Subscriber\SearchKitSubscriber' not found in /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/ext/search_kit/search_kit.php:14
  Stack trace:
  #0 /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/CRM/Utils/Hook.php(271): search_kit_civicrm_config(Object(CRM_Core_Config))
  #1 /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/CRM/Utils/Hook/DrupalBase.php(73): CRM_Utils_Hook->runHooks(Array, 'civicrm_config', 1, Object(CRM_Core_Config), NULL, NULL, NULL, NULL, NULL)
  #2 /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/Civi/Core/CiviEventDispatcher.php(248): CRM_Utils_Hook_DrupalBase->invokeViaUF(1, Object(CRM_Core_Config), NULL, NULL, NULL, NULL, NULL, 'civicrm_config')
  #3 /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php(214): Civi\Core\CiviEventDispatcher::delegateToUF(O in /var/sites/c/civicrm.example.net/public_html/sites/all/modules/civicrm/ext/search_kit/search_kit.php on line 14
  
  This is on Drupal 7.91 and CiviCRM 5.51.1, but it's been going on for a while.
  Edit 26/7/2022: I've been trying to test the command with cv, but I think something with our host is preventing it from running. I'm fairly beginner with Linux though, so maybe I'm missing something. I followed the instructions at https://github.com/civicrm/cv. I can't use sudo, but it seemed to work fine without. I don't have access to /usr/local/bin though, so just installed in ~/. Then when I try to run I see this:
  $ ls cv -l
  -rwxr-xr-x 1 username gid 1768622 Jul 26 12:15 cv
  $ cv
  bash: cv: command not found
  
  Edit 2/8/2022: Trying to run from my Drupal root folder results in the following:
  $ ~/cv list
  Fatal error: Class 'Phar' not found in /var/sites/c/civicrm.example.net/cv on line 10
  
  Edit 23/8/2022: Testing for Phar returns as follows:
  $ php -i | grep phar
  Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar, sqlsrv, zip
  Phar-based phar archives => enabled
  Tar-based phar archives => enabled
  ZIP-based phar archives => enabled
  phar.cache_list => no value => no value
  phar.readonly => On => On
  phar.require_hash => On => On
  
  Edit 2/9/2022: Trying to establish if cv is using a different php isn't going very well:
  $ which php
  bash: which: command not found
  $ /usr/bin/env which php
  /usr/bin/env: which: No such file or directory
  
  Edit 6/9/2022: PATH is as follows:
  $ echo $PATH
  /usr/local/bin:/usr/bin
  
  **Tags:** cron, searchkit, apiv4
  
  > **Comments:**
  > **username_1**: If you run the same command with `cv` does it give the same error? `cv api --user=cronuser Job.execute` I'm wondering if bin/cli.php maybe doesn't "boot enough" for search kit.  
  > **username_0**: @username_1 I've updated the post with the results. Maybe I've not installed it correctly, but I think maybe the host is blocking it somehow. I used to have Drush installed and it stopped working after an update the host did. That was last year some time though, long before this error, so I don't think the two are connected.  
  > **username_1**: Your home folder probably isn't in your path. Also it's easiest to run it from within the civi or drupal folder so it can figure out which site, so `cd /path/to/drupal`, then give the full path to cv e.g. `~/cv list`  
  > **username_0**: Huh. You have to specify full paths to execute a file in Linux? I'm even more of a beginner than I thought! Updated the question with the new error.  
  > **username_1**: No you don't but you had originally put cv in `~` which is unlikely to be in the PATH. Your new error suggests that php on that system does not include Phar, which is unusual but possible. If you run `php -i | grep phar` it should show some information about it if it's installed, otherwise I'd ask your host if php phar is enabled.  
  > **username_0**: Apologies, have been away. Thanks for the help. I've updated with the output. There's a bunch of lines that say 'enabled', but I don't really know what I'm reading. Does that look like it's installed?  
  > **username_1**: Ok that does look enabled. I wonder if it's possible cv is using a different php. If you run `/usr/bin/env which php` which php does it say? And is that different from just `which php`?  
  > **username_0**: Sorry, away again. Have updated with the result. Apparently I can't run which.  
  > **username_1**: That is bizarre. How about `echo $PATH` ? It's possible this is some kind of really locked down environment and CLI is meant for only really basic stuff. Back to the original problem, what method and how are you running cron? If you look in [ConfigAndLog](https://civicrm.stackexchange.com/questions/15931/where-are-the-configandlog-and-templates-c-directories) are there any errors that might seem related to your cron?  
  > **username_0**: Added the PATH above. I'm using the cli.php method, with the command in the first code block above. There's a load of stuff in ConfigAndLog over the weekend, but I think that's related to [this new error](https://civicrm.stackexchange.com/questions/42565/the-website-encountered-an-unexpected-error-please-try-again-later-when-tryi). There's nothing consistent that appears over the last couple of months this has been going on. It does feel like at some point our host massively locked down what we're able to do. I've never had cv working, but drush used to work and doesn't any longer.  
  > **username_1**: At this point it's probably best to ask your host what kind of environment this is. The PATH looks ok but there's something off somewhere.  
  
  ---
  
  ## 0 answers
  
  