OpenZFS 2.o AutoloadNotAllowedException

Nextcloud version : 21.0.0
Operating system and version : Ubuntu 20.04
Apache or nginx version : nginx/1.18.0 (Ubuntu)
PHP version : PHP 7.4.3

The issue you are facing:
Cannot install from fresh if /usr/share/nginx is a ZFS Dataset.

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

Steps to replicate it:

  1. Install from Install NextCloud on Ubuntu 20.04 with Nginx (LEMP Stack) - LinuxBabe. /usr/share/nginx is a ZFS dataset.
  2. Enter startup info from web browser
  3. Server throws Exception:
    {
    “reqId”: “zpZ5FMSmupiMdZsNdr9m”,
    “level”: 3,
    “time”: “2021-04-02T07:58:06+00:00”,
    “remoteAddr”: “188.76.27.38”,
    “user”: “–”,
    “app”: “index”,
    “method”: “POST”,
    “url”: “/index.php”,
    “message”: {
    “Exception”: “OCP\AutoloadNotAllowedException”,
    “Message”: “Autoload path not allowed: /usr/share/nginx/nextcloud/apps/files/lib/app.php”,
    “Code”: 0,
    “Trace”: [
    {
    “file”: “/usr/share/nginx/nextcloud/lib/autoloader.php”,
    “line”: 165,
    “function”: “isValidPath”,
    “class”: “OC\Autoloader”,
    “type”: “->”
    },
    {
    “function”: “load”,
    “class”: “OC\Autoloader”,
    “type”: “->”
    },
    {
    “function”: “spl_autoload_call”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/apps/files_sharing/lib/AppInfo/Application.php”,
    “line”: 171,
    “function”: “class_exists”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/apps/files_sharing/lib/AppInfo/Application.php”,
    “line”: 130,
    “function”: “setupSharingMenus”,
    “class”: “OCA\Files_Sharing\AppInfo\Application”,
    “type”: “->”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/lib/private/ServerContainer.php”,
    “line”: 108,
    “function”: “__construct”,
    “class”: “OCA\Files_Sharing\AppInfo\Application”,
    “type”: “->”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/lib/private/ServerContainer.php”,
    “line”: 177,
    “function”: “getAppContainer”,
    “class”: “OC\ServerContainer”,
    “type”: “->”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/lib/private/ServerContainer.php”,
    “line”: 144,
    “function”: “getAppContainerForService”,
    “class”: “OC\ServerContainer”,
    “type”: “->”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/lib/private/DB/MigrationService.php”,
    “line”: 497,
    “function”: “query”,
    “class”: “OC\ServerContainer”,
    “type”: “->”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/lib/private/DB/MigrationService.php”,
    “line”: 451,
    “function”: “createInstance”,
    “class”: “OC\DB\MigrationService”,
    “type”: “->”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/lib/private/DB/MigrationService.php”,
    “line”: 418,
    “function”: “migrateSchemaOnly”,
    “class”: “OC\DB\MigrationService”,
    “type”: “->”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/lib/private/Installer.php”,
    “line”: 616,
    “function”: “migrate”,
    “class”: “OC\DB\MigrationService”,
    “type”: “->”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/lib/private/Installer.php”,
    “line”: 579,
    “function”: “installShippedApp”,
    “class”: “OC\Installer”,
    “type”: “::”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/lib/private/Setup.php”,
    “line”: 411,
    “function”: “installShippedApps”,
    “class”: “OC\Installer”,
    “type”: “::”
    },
    {
    “file”: “/usr/share/nginx/nextcloud/core/Controller/SetupController.php”,
    “line”: 75,
    “function”: “install”,
    “class”: “OC\Setup”,
    “type”: “->”,
    “args”: [
    “*** sensitive parameters replaced "
    ]
    },
    {
    “file”: “/usr/share/nginx/nextcloud/lib/base.php”,
    “line”: 932,
    “function”: “run”,
    “class”: “OC\Core\Controller\SetupController”,
    “type”: “->”,
    “args”: [
    "
    sensitive parameters replaced ***”
    ]
    },
    {
    “file”: “/usr/share/nginx/nextcloud/index.php”,
    “line”: 37,
    “function”: “handleRequest”,
    “class”: “OC”,
    “type”: “::”
    }
    ],
    “File”: “/usr/share/nginx/nextcloud/lib/autoloader.php”,
    “Line”: 140,
    “CustomMessage”: “–”
    },
    “userAgent”: “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15”,
    “version”: “21.0.0.18”
    }

The output of your Nextcloud log in Admin > Logging:

Web interface do not working.

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

<?php
$CONFIG = array (
  'instanceid' => 'ocp28sa73igj',
  'passwordsalt' => '*',
  'secret' => '*',
  'trusted_domains' =>
  array (
    0 => 'nc.*.pw',
  ),
  'datadirectory' => '/usr/share/nginx/nextcloud-data',
  'dbtype' => 'mysql',
  'version' => '21.0.0.18',
  'overwrite.cli.url' => 'https://nc.*.pw',
  'dbname' => 'ncd',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncu',
  'dbpassword' => '*',
  'installed' => true,
);

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

(Irrelevant)

I can make it works if change last line of code of function isValidPath from nextcloud/lib/autoloader.php to:

    protected function isValidPath(string $fullPath): bool {
            foreach ($this->validRoots as $root => $true) {
                    if (substr($fullPath, 0, strlen($root) + 1) === $root . '/') {
                            return true;
                    }
            }
            return true;
            //throw new AutoloadNotAllowedException($fullPath);
    }