Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer memory exhausted on shared host

A previously working sandbox on a shared FreeBSD host now fails to run composer update or install with a memory exhausted error. Before yesterday I was able to run php ./composer.phar update without a problem. I do not believe that more memory is required. I can update the project on a Windows system without any issue. What variables other than memory size contribute to the memory exhausted error?

To test this I moved the contents of .../vendor and the composer.lock file to a different directory then ran php ./composer.phar install --prefer-dist. [Composer is in the project directory so that I can update it locally rather than expect the host master to keep it updated.] The above command results in:

% php ./composer.phar install --prefer-dist
Loading composer repositories with package information
Updating dependencies (including require-dev)
PHP Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to allocate 134217728 bytes) in phar:///home/projectmana/www3.projectmana.org/composer.phar/src/Composer/DependencyResolver/Solver.php on line 220

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 134217728 bytes) in phar:///home/projectmana/www3.projectmana.org/composer.phar/src/Composer/DependencyResolver/Solver.php on line 220

Composer is version 1.20

composer.json used:

{
    "name": "truckee/projectmana",
    "license": "MIT",
    "type": "project",
    "description": "Project MANA administrative application",
    "autoload": {
        "psr-0": {
            "": "src/"
        }
    },
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "jquery/jquery",
                "version": "1.11.1",
                "dist": {
                    "url": "https://code.jquery.com/jquery-1.11.1.js",
                    "type": "file"
                }
            }
        }
    ],
    "require": {
        "braincrafted/bootstrap-bundle": "~2.0",
        "doctrine/doctrine-bundle": "~1.4",
        "doctrine/doctrine-fixtures-bundle": "^2.3",
        "doctrine/orm": "^2.4.8",
        "friendsofsymfony/user-bundle": "~2.0@dev",
        "incenteev/composer-parameter-handler": "~2.0",
        "javiereguiluz/easyadmin-bundle": "~1.1",
        "jms/security-extra-bundle": "~1.5",
        "jquery/jquery": "1.11.*",
        "knplabs/knp-menu-bundle": "~2.0",
        "nelmio/alice": "^2.1",
        "oyejorge/less.php": "~1.5",
        "paragonie/random_compat": "^2.0",
        "php": ">=5.3.9",
        "psliwa/pdf-bundle": "dev-master",
        "sensio/distribution-bundle": "~4.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "symfony/assetic-bundle": "dev-master",
        "symfony/monolog-bundle": "~2.4",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/symfony": "2.8.*",
        "twbs/bootstrap": "3.0.*",
        "twig/extensions": "1.0.*"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Braincrafted\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::install"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Braincrafted\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::install"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "minimum-stability": "stable",
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "htdocs",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.3-dev"
        },
        "repositories": [
            {
                "type": "composer",
                "url": "http://packages.zendframework.com/"
            },
            {
                "type": "composer",
                "url": "http://packagist.org/"
            }
        ]
    },
    "require-dev": {
        "liip/functional-test-bundle": "^1.4",
        "symfony/phpunit-bridge": "^3.0"
    }
}

Edit: Available memory:

% php -r "echo(ini_get('memory_limit'));"
128M

Requested free -m: % free -m free: Command not found.

with -vv --profile:

% composer update -vv --profile
[9.9MB/0.01s] Loading composer repositories with package information
[10.5MB/0.80s] Updating dependencies (including require-dev)
PHP Fatal error: ...

Edit #2, fatal error (using composer 1.1.0) continued, as it differs from that above:

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

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 32 bytes) in phar:///usr/local/bin/composer.phar/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
like image 500
geoB Avatar asked Sep 02 '16 22:09

geoB


2 Answers

you can try this, I'm success

php -d memory_limit=-1 /usr/local/bin/composer/composer.phar require guzzlehttp/guzzle

this is my first answer!!!wow

enter image description here

like image 134
高璐璐 Avatar answered Oct 13 '22 00:10

高璐璐


Composer update use a lot memory to resolve dependencies

Your only option on server with so little memory is to provide composer.lock either by committing it to the repository or copy to server from continuous integration server.

There is no other way to run composer on server with 128mb ram

like image 36
Konrad Podgórski Avatar answered Oct 13 '22 00:10

Konrad Podgórski