Write errors for nfs mount

I can’t seem to get nextcloud to see that its data directory is indeed writable by the http user.

[root@lin-virt02 nextcloud]# sudo -u http ls -alh data
total 436K
drwxrwxrwx  1 http http  188 Nov  9 04:00 .
drwxr-x--- 16 http http 4.0K Nov  9 03:54 ..
drwxr-x---  1 http http   76 Sep 30 02:03 admin
drwxr-x---  1 http http  146 Sep 27 19:19 appdata_ocb0vuuo4fin
drwxr-x---  1 http http   26 Oct 25 19:14 files_external
-rw-r--r--  1 http http  324 Sep 27 17:43 .htaccess
-rw-r-----  1 http http    0 Sep 27 17:43 index.html
-rw-r-----  1 http http 428K Nov  7 15:23 nextcloud.log
-rw-r-----  1 http http    0 Sep 27 17:43 .ocdata

[root@lin-virt02 nextcloud]# sudo -u http touch data/test

[root@lin-virt02 nextcloud]# sudo -u http ls -alh data
total 436K
drwxrwxrwx  1 http http  196 Nov  9 04:00 .
drwxr-x--- 16 http http 4.0K Nov  9 03:54 ..
drwxr-x---  1 http http   76 Sep 30 02:03 admin
drwxr-x---  1 http http  146 Sep 27 19:19 appdata_ocb0vuuo4fin
drwxr-x---  1 http http   26 Oct 25 19:14 files_external
-rw-r--r--  1 http http  324 Sep 27 17:43 .htaccess
-rw-r-----  1 http http    0 Sep 27 17:43 index.html
-rw-r-----  1 http http 428K Nov  7 15:23 nextcloud.log
-rw-r-----  1 http http    0 Sep 27 17:43 .ocdata
-rw-r--r--  1 http http    0 Nov  9 04:00 test

[root@lin-virt02 nextcloud]# sudo -u http php occ files:scan admin
Your data directory is not writable
Permissions can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/12/go.php?to=admin-dir_permissions.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /usr/share/webapps/nextcloud/lib/private/Console/Application.php:145
Stack trace:
#0 /usr/share/webapps/nextcloud/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /usr/share/webapps/nextcloud/occ(11): require_once('/usr/share/weba...')

fstab:
synology_url:/volume1/Nextcloud /usr/share/webapps/nextcloud/data nfs rsize=8192,wsize=8192,_netdev,noauto,x-systemd.automount 0 0

Any help would be appreciated!

For anyone else having this error its a bug with there filesystem checks.

You can fix this by commenting out

/usr/share/webapps/nextcloud/lib/private/legacy/util.php

#                       } else if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) {
#                               //common hint for all file permissions error messages
#                               $permissionsHint = $l->t('Permissions can usually be fixed by giving the webserver write access to the root directory. See %s.',
#                                       [$urlGenerator->linkToDocs('admin-dir_permissions')]);
#                               $errors[] = [
#                                       'error' => 'Your data directory is not writable',
#                                       'hint' => $permissionsHint
#                               ];

/usr/share/webapps/nextcloud/lib/private/Console/Application.php

#               if ($input->getFirstArgument() !== 'check') {
#                       $errors = \OC_Util::checkServer(\OC::$server->getSystemConfig());
#                       if (!empty($errors)) {
#                               foreach ($errors as $error) {
#                                       $output->writeln((string)$error['error']);
#                                       $output->writeln((string)$error['hint']);
#                                       $output->writeln('');
#                               }
#                               throw new \Exception("Environment not properly prepared.");
#                       }
#               }

Nextcloud is running on an arch lamp stack php version 7

1 Like

I can verify that @Xarin’s solution works on Nextcloud 15. Sad that this issue is still not resolved…

still not solved…getting crazy with NFS /data mount because of no write/read permission on folder

I # following files:

/usr/src/nextcloud/lib/private/legacy/OC_Util.php
/var/www/html/lib/private/legacy/OC_Util.php

lines:
“Check if there is a writable install folder.” and "Check if config folder is writable.

Is it ok now? Where can I find this “/usr/share/webapps/nextcloud/lib/private/legacy/util.php” file? Does it work with Docker-based install? I try to install a Nextcloud AIO instance but cannot make it working even though my www-data user can perfectly write in the /mnt/ncdata folder…