Undefined class constant 'MAJOR_VERSION'"

Nextcloud version (eg, 20.0.5): 21.0.2
Operating system and version (eg, Ubuntu 20.04): 20.04
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4
PHP version (eg, 7.4): `7.3’

The issue you are facing:

Nextcloud broken

Is this the first time you’ve seen this error? Y

Steps to replicate it:

  1. Updated to Nextcloud 21

The output of your Nextcloud log in Admin > Logging:

{"reqId":"TMiRCXoaBkhC17QhUpvS","level":3,"time":"2021-06-13T10:44:03+00:00","remoteAddr":"192.168.1.1","user":"danhnguyen","app":"index","method":"GET","url":"/nextcloud/index.php/apps/calendar/","message":{"Exception":"Error","Message":"Undefined class constant 'MAJOR_VERSION'","Code":0,"Trace":[{"file":"/var/www/nextcloud/3rdparty/guzzlehttp/guzzle/src/functions.php","line":71,"function":"defaultUserAgent","class":"GuzzleHttp\\Utils","type":"::","args":[]},{"file":"/var/www/nextcloud/apps/files_external_onedrive/vendor/guzzlehttp/guzzle/src/Client.php","line":194,"function":"GuzzleHttp\\default_user_agent","args":[]},{"file":"/var/www/nextcloud/apps/files_external_onedrive/vendor/guzzlehttp/guzzle/src/Client.php","line":75,"function":"configureDefaults","class":"GuzzleHttp\\Client","type":"->","args":[{"handler":{"__class__":"GuzzleHttp\\HandlerStack"}}]},{"file":"/var/www/nextcloud/lib/private/Http/Client/ClientService.php","line":62,"function":"__construct","class":"GuzzleHttp\\Client","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/OCS/DiscoveryService.php","line":55,"function":"newClient","class":"OC\\Http\\Client\\ClientService","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/Server.php","line":1264,"function":"__construct","class":"OC\\OCS\\DiscoveryService","type":"->","args":[{"__class__":"OC\\Memcache\\Factory"},{"__class__":"OC\\Http\\Client\\ClientService"}]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":155,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":122,"function":"offsetGet","class":"Pimple\\Container","type":"->","args":["OCP\\OCS\\IDiscoveryService"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":137,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCP\\OCS\\IDiscoveryService",false]},{"file":"/var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":434,"function":"query","class":"OC\\ServerContainer","type":"->","args":["OCP\\OCS\\IDiscoveryService",true]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":87,"function":"query","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["OCP\\OCS\\IDiscoveryService",true]},{"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":101,"function":"array_map","args":[{"__class__":"Closure"},[{"name":"addressHandler","__class__":"ReflectionParameter"},{"name":"httpClientService","__class__":"ReflectionParameter"},"*** sensitive parameter replaced ***",{"name":"jobList","__class__":"ReflectionParameter"},{"name":"federationProviderManager","__class__":"ReflectionParameter"},"And 2 more entries, set log level to debug to see all entries"]]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":109,"function":"buildClass","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":[{"name":"OCA\\FederatedFileSharing\\Notifications","__class__":"ReflectionClass"}]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":126,"function":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\FederatedFileSharing\\Notifications"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":459,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\FederatedFileSharing\\Notifications"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":431,"function":"queryNoFallback","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["OCA\\FederatedFileSharing\\Notifications"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":87,"function":"query","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["OCA\\FederatedFileSharing\\Notifications",true]},{"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":101,"function":"array_map","args":[{"__class__":"Closure"},[{"name":"connection","__class__":"ReflectionParameter"},{"name":"addressHandler","__class__":"ReflectionParameter"},"*** sensitive parameter replaced ***",{"name":"tokenHandler","__class__":"ReflectionParameter"},{"name":"l10n","__class__":"ReflectionParameter"},"And 7 more entries, set log level to debug to see all entries"]]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":109,"function":"buildClass","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":[{"name":"OCA\\FederatedFileSharing\\FederatedShareProvider","__class__":"ReflectionClass"}]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":126,"function":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\FederatedFileSharing\\FederatedShareProvider"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":459,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\FederatedFileSharing\\FederatedShareProvider"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":146,"function":"queryNoFallback","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["OCA\\FederatedFileSharing\\FederatedShareProvider"]},{"file":"/var/www/nextcloud/apps/provisioning_api/lib/Capabilities.php","line":50,"function":"query","class":"OC\\ServerContainer","type":"->","args":["OCA\\FederatedFileSharing\\FederatedShareProvider"]},{"file":"/var/www/nextcloud/lib/private/CapabilitiesManager.php","line":72,"function":"getCapabilities","class":"OCA\\Provisioning_API\\Capabilities","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/Template/JSConfigHelper.php","line":183,"function":"getCapabilities","class":"OC\\CapabilitiesManager","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":211,"function":"getConfig","class":"OC\\Template\\JSConfigHelper","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":183,"function":"__construct","class":"OC\\TemplateLayout","type":"->","args":["user","calendar"]},{"file":"/var/www/nextcloud/lib/public/AppFramework/Http/TemplateResponse.php","line":210,"function":"fetchPage","class":"OC_Template","type":"->","args":[{"appVersion":"1.7.3","isIE":false,"defaultColor":"#0082C9","shareeCanEditShares":"no","shareeCanEditCalendarProperties":"yes","0":"And 10 more entries, set log level to debug to see all entries"}]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":172,"function":"render","class":"OCP\\AppFramework\\Http\\TemplateResponse","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Calendar\\Controller\\ViewController"},"index"]},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["ViewController","index",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"calendar.view.index"}]},{"file":"/var/www/nextcloud/lib/base.php","line":993,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/calendar/"]},{"file":"/var/www/nextcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/nextcloud/3rdparty/guzzlehttp/guzzle/src/Utils.php","Line":118,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36","version":"21.0.2.1"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

$CONFIG = array (
  'instanceid' => 'x',
  'passwordsalt' => 'x',
  'secret' => 'x/WKcRlSU',x
  'trusted_domains' =>
  array (
    x
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'overwrite.cli.url' => 'x',
  'dbtype' => 'mysql',
  'version' => '21.0.2.1',
  'dbname' => x,
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'x',
  'dbpassword' => 'x',
  'installed' => true,
  'maintenance' => false,
  'appstoreurl' => 'https://apps.nextcloud.com/api/v0',
  'theme' => '',
  'loglevel' => 2,
  'defaultapp' => 'calendar',
  'auth.bruteforce.protection.enaled' => true,
  'htaccess.RewriteBase' => '/nextcloud',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'mail_from_address' => 'x',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_domain' => 'x',
  'mail_smtphost' => 'x',
  'mail_smtpport' => '465',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'x',
  'mail_smtppassword' => 'x',
  'mail_smtpsecure' => 'ssl',
  'twofactor_enforced' => 'false',
  'twofactor_enforced_groups' =>
  array (
  ),
  'twofactor_enforced_excluded_groups' =>
  array (
  ),
  'app_install_overwrite' =>
  array (
    0 => 'mail',
    1 => 'ldapcontacts',
    2 => 'keeweb',
   3 => 'files_external_onedrive',
    4 => 'calendar',
    5 => 'qownnotesapi',
    6 => 'contacts',
  ),
  'encryption.legacy_format_support' => true,
  'encryption.key_storage_migrated' => false,
  'updater.secret' => '$2y$10$x',


The output of your Apache/nginx/system log in /var/log/____:

PASTE HERE

Upgraded to NC 21, there were some incompatible apps including the default calendar, contacts. From seeing other forums, files_external_onedrive is problematic but i cannot disable or run any occ commands because i get the error

when running

An unhandled exception has been thrown:
Error: Undefined class constant 'MAJOR_VERSION' in /var/www/nextcloud/3rdparty/guzzlehttp/guzzle/src/Utils.php:118
Stack trace:
#0 /var/www/nextcloud/3rdparty/guzzlehttp/guzzle/src/functions.php(71): GuzzleHttp\Utils::defaultUserAgent()
#1 /var/www/nextcloud/apps/files_external_onedrive/vendor/guzzlehttp/guzzle/src/Client.php(194): GuzzleHttp\default_user_agent()
#2 /var/www/nextcloud/apps/files_external_onedrive/vendor/guzzlehttp/guzzle/src/Client.php(75): GuzzleHttp\Client->configureDefaults(Array)
#3 /var/www/nextcloud/lib/private/Http/Client/ClientService.php(62): GuzzleHttp\Client->__construct()
#4 /var/www/nextcloud/lib/private/OCS/DiscoveryService.php(55): OC\Http\Client\ClientService->newClient()
#5 /var/www/nextcloud/lib/private/Server.php(1264): OC\OCS\DiscoveryService->__construct(Object(OC\Memcache\Factory), Object(OC\Http\Client\ClientService))
#6 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\Server->OC\{closure}(Object(OC\Server))
#7 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#8 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet('OCP\\OCS\\IDiscov...')
#9 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Utility\SimpleContainer->query('OCP\\OCS\\IDiscov...', false)
#10 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(434): OC\ServerContainer->query('OCP\\OCS\\IDiscov...', true)
#11 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(87): OC\AppFramework\DependencyInjection\DIContainer->query('OCP\\OCS\\IDiscov...', true)
#12 [internal function]: OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(ReflectionParameter))
#13 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(101): array_map(Object(Closure), Array)
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(109): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(126): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Federation\\...')
#16 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(459): OC\AppFramework\Utility\SimpleContainer->query('OCA\\Federation\\...')
#17 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(431): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Federation\\...')
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(87): OC\AppFramework\DependencyInjection\DIContainer->query('OCA\\Federation\\...', true)
#19 [internal function]: OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(ReflectionParameter))
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(101): array_map(Object(Closure), Array)
#21 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(109): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(126): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Federation\\...')
#23 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(459): OC\AppFramework\Utility\SimpleContainer->query('OCA\\Federation\\...')
#24 /var/www/nextcloud/lib/private/ServerContainer.php(146): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Federation\\...')
#25 /var/www/nextcloud/lib/private/Console/Application.php(221): OC\ServerContainer->query('OCA\\Federation\\...')
#26 /var/www/nextcloud/lib/private/Console/Application.php(136): OC\Console\Application->loadCommandsFromInfoXml(Array)
#27 /var/www/nextcloud/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#29 {x}@x:/var/www/nextcloud$

Fixed it myself again. The files_external_onedrive was not in the 3rdparty folder but instead the app folder. Deleting this folder completely resolved it