Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Out of memory errors when running composer #34

Open
byrond opened this issue Apr 24, 2017 · 2 comments
Open

Out of memory errors when running composer #34

byrond opened this issue Apr 24, 2017 · 2 comments

Comments

@byrond
Copy link
Contributor

byrond commented Apr 24, 2017

Trying to run 'composer require...' or 'composer update' within the-vagrant (via vagrant ssh) gives the following error:

PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 32 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Checked the /etc/php5/cli/php.ini, and 'memory_limit = -1' is present, but I suspect the setting isn't taking effect. Running the following gives a result of '256M':

php -r "echo ini_get('memory_limit').PHP_EOL;"

Adding the memory_limit setting on the command line allows 'composer update' to succeed. For example:

php -d memory_limit=-1 /usr/local/bin/composer update

(See also https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors)

@byrond
Copy link
Contributor Author

byrond commented Apr 24, 2017

Running php --ini gives the following output:

Configuration File (php.ini) Path: /etc/php/5.6/cli
Loaded Configuration File:         /etc/php/5.6/cli/php.ini

Recommend updating the-vagrant/conf/vagrant/provisioning/roles/php/tasks/main.yml to not set the 256M memory_limit in cli/php.ini or set it to '-1' separately.

@becw
Copy link
Member

becw commented Jun 27, 2018

I haven't encountered this recently, I think because more recent versions of Composer + more recent versions of PHP are more efficient in this way.

When I have run into this, there are a couple of things that have worked for me:

  • Make sure XDebug is disabled on the CLI
  • Update composer (try sudo -H composer self-update)
  • Increase the memory limit for the CLI specifically
  • ... and, as you mentioned: verifying the php.ini file for the version of PHP you're running. The default PHP config location changed when the PHP 7 packages were standardized, so that all paths include the version number as its own path component. Several things in the-vagrant have referred to the wrong path over time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants