Nextcloud container not starting: Interface OCP\Security\ICrypto not found

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.5
  • Operating system and version (e.g., Ubuntu 24.04):
    • Kubernetes
  • Is this the first time you’ve seen this error? (Yes / No):
    • yes
  • When did this problem seem to first start?
    • After restore of a backup
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Truecharts -> Using image nextcloud-fpm:v31.0.5

Summary of the issue you are facing:

I had to roll back to an older snapshot of the /var/www/html storage folder (the snapshot was taken on 14th May 2025, probably with an older nextcloud version).

Now when the container starts i get the following error:

An unhandled exception has been thrown:
Error: Interface "OCP\Security\ICrypto" not found in /var/www/html/lib/private/Security/Crypto.php:27
Stack trace:
#0 /var/www/html/lib/composer/composer/ClassLoader.php(576): include()
#1 /var/www/html/lib/composer/composer/ClassLoader.php(427): Composer\Autoload\{closure}('/var/www/html/l...')
nextcloud #2 [internal function]: Composer\Autoload\ClassLoader->loadClass('OC\\Security\\Cry...')
nextcloud #3 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(104): ReflectionClass->__construct('OC\\Security\\Cry...')
nextcloud #4 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(124): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Security\\Cry...')
nextcloud #5 /var/www/html/lib/private/ServerContainer.php(155): OC\AppFramework\Utility\SimpleContainer->query('OC\\Security\\Cry...', true)
...

Does anyone have an idea what could cause this and how i can fix it?

I think i don’t have to run a composer install inside a container, am i right?