Update will always fail, beacuse of: Directory not empty

If I want to update an App (e.x. Calendar App), it will fail and in the logs I found this messages:

Log Messages
{
    "reqId": "ZAdZU2kxL4ZVtGqssFurUQACzBw",
    "level": 3,
    "time": "2023-03-07T15:33:42+00:00",
    "remoteAddr": "84.227.8.184",
    "user": "example_admin",
    "app": "PHP",
    "method": "GET",
    "url": "/index.php/settings/apps/update/calendar",
    "message": "rmdir(/home/example/www/nextcloud/apps/calendar/img/illustrations) [<a href='https://secure.php.net/manual/en/function.rmdir.php'>function.rmdir.php</a>]: Directory not empty at /home/example/www/nextcloud/lib/private/legacy/OC_Helper.php#177",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0",
    "version": "25.0.3.2",
    "exception": {
        "Exception": "Error",
        "Message": "rmdir(/home/example/www/nextcloud/apps/calendar/img/illustrations) [<a href='https://secure.php.net/manual/en/function.rmdir.php'>function.rmdir.php</a>]: Directory not empty at /home/example/www/nextcloud/lib/private/legacy/OC_Helper.php#177",
        "Code": 0,
        "Trace": [
            {
                "function": "onError",
                "class": "OC\\Log\\ErrorHandler",
                "type": "::",
                "args": [
                    2,
                    "rmdir(/home/example/www/nextcloud/apps/calendar/img/illustrations) [<a href='https://secure.php.net/manual/en/function.rmdir.php'>function.rmdir.php</a>]: Directory not empty",
                    "/home/example/www/nextcloud/lib/private/legacy/OC_Helper.php",
                    177
                ]
            },
            {
                "file": "/home/example/www/nextcloud/lib/private/legacy/OC_Helper.php",
                "line": 177,
                "function": "rmdir",
                "args": [
                    "/home/example/www/nextcloud/apps/calendar/img/illustrations"
                ]
            },
            {
                "file": "/home/example/www/nextcloud/lib/private/Installer.php",
                "line": 367,
                "function": "rmdirr",
                "class": "OC_Helper",
                "type": "::",
                "args": [
                    "/home/example/www/nextcloud/apps/calendar"
                ]
            },
            {
                "file": "/home/example/www/nextcloud/lib/private/Installer.php",
                "line": 193,
                "function": "downloadApp",
                "class": "OC\\Installer",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***",
                    false
                ]
            },
            {
                "file": "/home/example/www/nextcloud/apps/settings/lib/Controller/AppSettingsController.php",
                "line": 535,
                "function": "updateAppstoreApp",
                "class": "OC\\Installer",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/home/example/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
                "line": 225,
                "function": "updateApp",
                "class": "OCA\\Settings\\Controller\\AppSettingsController",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/home/example/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
                "line": 133,
                "function": "executeController",
                "class": "OC\\AppFramework\\Http\\Dispatcher",
                "type": "->",
                "args": [
                    {
                        "__class__": "OCA\\Settings\\Controller\\AppSettingsController"
                    },
                    "updateApp"
                ]
            },
            {
                "file": "/home/example/www/nextcloud/lib/private/AppFramework/App.php",
                "line": 172,
                "function": "dispatch",
                "class": "OC\\AppFramework\\Http\\Dispatcher",
                "type": "->",
                "args": [
                    {
                        "__class__": "OCA\\Settings\\Controller\\AppSettingsController"
                    },
                    "updateApp"
                ]
            },
            {
                "file": "/home/example/www/nextcloud/lib/private/Route/Router.php",
                "line": 298,
                "function": "main",
                "class": "OC\\AppFramework\\App",
                "type": "::",
                "args": [
                    "OCA\\Settings\\Controller\\AppSettingsController",
                    "updateApp",
                    {
                        "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
                    },
                    [
                        "*** sensitive parameters replaced ***",
                        "settings.AppSettings.updateApp"
                    ]
                ]
            },
            {
                "file": "/home/example/www/nextcloud/lib/base.php",
                "line": 1047,
                "function": "match",
                "class": "OC\\Route\\Router",
                "type": "->",
                "args": [
                    "/settings/apps/update/calendar"
                ]
            },
            {
                "file": "/home/example/www/nextcloud/index.php",
                "line": 36,
                "function": "handleRequest",
                "class": "OC",
                "type": "::",
                "args": []
            }
        ],
        "File": "/home/example/www/nextcloud/lib/private/Log/ErrorHandler.php",
        "Line": 92,
        "CustomMessage": "--"
    }
}

Nextcloud version: Nextcloud Hub 3 (25.0.3)
Operating system and version: FreeBSD 12.4
Apache or nginx version: Apache/2.4.55
PHP version: 8.1

The output of your config.php file:

<?php
$CONFIG = array (
  'instanceid' => 'exampleid',
  'passwordsalt' => 'xxxx',
  'secret' => 'xxx',
  'trusted_domains' =>
  array (
    0 => 'example.com',
  ),
  'datadirectory' => '/home/example/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '25.0.3.2',
  'overwrite.cli.url' => 'https://example.com',
  'dbname' => 'xxx',
  'dbhost' => 'xxx',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xxx',
  'dbpassword' => 'xxx',
  'installed' => true,
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' =>
  array (
  ),
  'twofactor_enforced_excluded_groups' =>
  array (
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'admin',
  'mail_domain' => 'example.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.example.com',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'example@example.com',
  'mail_smtppassword' => 'xxx',
  'maintenance' => FALSE,
);

Permissions of the apps folder:

drwxr-xr-x

Permissions of the apps/calendar folder:

drwxr-xr-x

For the rmdir command, I think that the folder has to be empty. Did you place things there yourself and normally it is empty?
Quick and dirty solution is to just delete the whole calendar folder manually, then install the calendar app again, it will then get the most recent version from the app store. As always, do a backup before.

Thank you very much. The Quick and dirty solution works! :+1:
No I have not put things there myself, but I have the same problem with almost every app. And I wonder why that is? It would be much more convenient to be able to update this directly via the UI.