Memory error when running occ commands

Nextcloud version (eg, 20.0.5): 24.0.7
Operating system and version (eg, Ubuntu 20.04): Linux Mint 21
Apache or nginx version (eg, Apache 2.4.25): NC AIO
PHP version (eg, 7.4): NC AIO

The issue you are facing:
I got an error saying that an update for NC or an app was available but needed to be applied through command line. I tried running sudo -u www-data php occ upgrade but got the error:
Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 442368 bytes) in /var/www/html/3rdparty/composer/autoload_real.php on line 35

Is this the first time you’ve seen this error? (Y/N): Y

  • I tried asking a question on the GitHub for the NC Server but they directed me here.

Steps to replicate it:

  1. I just simply installed using the Nextcloud AIO install instructions
  2. I was able to get it working when I opened occ and added in the line ini_set('memory_limit', '512M');, which I confirmed was the memory limit from php -i.

Hi, see GitHub - nextcloud/all-in-one: Nextcloud AIO stands for Nextcloud All In One and provides easy deployment and maintenance with most features included in this one Nextcloud instance.

Why is there a difference if I were to run it within the container as the www-data user vs from outside the container? If I exec into the container and run sudo -u www-data php occ upgrade is still errors out.

The correct command would be sudo -E -u www-data php occ upgrade if you really want to use sudo for this.

Ok, thanks. I’ll keep that in mind