skip to Main Content

I am installing passport in laravel by composer using command

  $ composer require laravel/passport

    Using version ^6.0 for laravel/passport
    ./composer.json has been updated
    Loading composer repositories with package information
    Updating dependencies (including require-dev)

    mmap() failed: [12] Cannot allocate memory

    mmap() failed: [12] Cannot allocate memory

    Fatal error: Out of memory (allocated 483401728) (tried to allocate 8388608 bytes) in phar:///opt/cpanel/composer/bin/composer/src/Composer/DependencyResolver/Solver.php on line 220

I got above errors please help me if you have any solutions.

4

Answers


  1. Source

    Memory limit errors.

    Composer may sometimes fail on some commands with this message:

    PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted <…>

    In this case, the PHP memory_limit should be increased.

    Note: Composer internally increases the `memory_limit` to 1.5G.
    

    To get the current memory_limit value, run:

    php -r “echo ini_get(‘memory_limit’).PHP_EOL;”

    Try increasing the limit in your php.ini file (ex. /etc/php5/cli/php.ini for Debian-like systems):

    Use -1 for unlimited or define an explicit value like 2G
    memory_limit = -1

    Composer also respects a memory limit defined by the COMPOSER_MEMORY_LIMIT environment variable:

    COMPOSER_MEMORY_LIMIT=-1 composer.phar <…>

    Or, you can increase the limit with a command-line argument:

    php -d memory_limit=-1 composer.phar <…>

    This issue can also happen on cPanel instances, when the shell fork bomb protection is activated. For more information, see the documentation of the fork bomb feature on the cPanel site.

    This answer might also be useful.

    Login or Signup to reply.
  2. Try the following steps:

    sudo fallocate -l 2G /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    
    Login or Signup to reply.
  3. In the root of your project in the composer.json in the line of require “require”: {"laravel/ui": "^1.1"} and next, composer update

    Login or Signup to reply.
  4. I was able to install Passport by temporarily removing PHP’s memory limit. I found this idea here: https://laravel.io/forum/02-11-2014-composer-running-out-of-memory

    $ php -d memory_limit=-1 /usr/local/bin/composer require laravel/passport --verbose --profile
    

    I like this solution because it overrides the PHP limit only once, so it allows you to push forward without any lasting affects. This will allow you to wait and see if you continue to get issues later, such as in the production environment, etc.

    The default PHP installation allocates 500 MB~ RAM I believe, and when I ran that above command, it consumed 712 MB of RAM.

    Extra note

    At that above URL, there is also mention of committing the composer.lock file in the production environment. Historically, it can be a concern if, for example, you are developing localmachine on MacOS or Windows and then your production environment is Linux. It might not be likely, but it is possible a person could experience issues due to arbitrary packages determining what dependencies to select based on the detected operating system. If you commit the lock file, you are caching the packages/versions. The performance benefits will stem from that, but caching breeds rigidity.

    I’m not sure of the true likelihood of what I’m saying. I’m saying this about composer, but I’ve seen it with npm and JavaScript.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search