Having some trouble getting past this memory error. It seems like I should have plenty of RAM free to install. Also, I looked in another thread that recommended against using Swap (though if you think that is the way to go please explain how to do it if possible, since I don't know).

I am using Amazon Lightsail LAMP with Bitnami.

Error:

bitnami@ip-:/opt/bitnami/apache/htdocs$ composer require fof/user-directory
Using version 0.3.4 for fof/user-directory
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals

PHP Warning: proc_open(): fork failed - Cannot allocate memory in phar:///opt/bitnami/php
/bin/composer.phar/vendor/symfony/console/Application.php on line 952

Warning: proc_open(): fork failed - Cannot allocate memory in phar:///opt/bitnami/php/bin/
composer.phar/vendor/symfony/console/Application.php on line 952


[ErrorException]
proc_open(): fork failed - Cannot allocate memory


require [--dev] [--prefer-source] [--prefer-dist] [--fixed] [--no-progress] [--no-suggest]
[--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-wit
h-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-p
ackages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--]
[<packages>]...

bitnami@ip:/opt/bitnami/apache/htdocs$ free -m
total used free shared buff/cache available
Mem: 1995 760 1093 46 141 1067
Swap: 0 0 0
bitnami@ip:/opt/bitnami/apache/htdocs$

    cmwetherell Also, I looked in another thread that recommended against using Swap (though if you think that is the way to go please explain how to do it if possible, since I don't know).

    Don't know if a swap partition is the solution, but I used this manual while installing Flarum on a system with 1GB RAM which didn't offer me the full 1GB for composer really:
    https://www.vultr.com/docs/setup-swap-file-on-linux

    It is straight forward and really easy to do (even I managed it 😅 ). You could at least try it if no other solution is provided.

    cmwetherell have you tried to increase the memory for PHP via PHP's ini config files? Make sure to edit the memory for the cli version of PHP and not the web version, as there's often two different config files.

      clarkwinkelmann This didn't solve my problem. I got the same error after changing php.ini memory to memory_limit = 1028M. It was 256M. I am on a 2GB VPS with 1100M free based on $ free -m

      I changed php.ini at /opt/bitnami/php/lib/php.ini based on the following

      $ php --ini
      Configuration File (php.ini) Path: /opt/bitnami/php/lib
      Loaded Configuration File: /opt/bitnami/php/lib/php.ini
      Scan for additional .ini files in: /opt/bitnami/php/etc/conf.d
      Additional .ini files parsed: (none)

        cmwetherell glad you got it working!

        I have split the discussion to keep things better organized and easier to find in the future.