Composer running out of memory when trying to install or update

Sometimes when running composer update or composer install, we run into a weird memory related issue, here is an easy workaround.

If you have been getting a similar error as the one I show below when trying to install a composer package or update your dependencies, you know how frustrating it is.

There is a workaround though that works fine until this hopefully gets fixed in Composer version 2.

The (annoying) error (yours might look different, but it's essentially the same problem):

PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 144115188075867549 bytes) in phar:///bin/composer.phar/src/Composer/Util/RemoteFilesystem.php on line 179

The temporary workaround:

php -d memory_limit=-1 /usr/local/bin/composer require [name of package, or update, or install]