zoukankan      html  css  js  c++  java
  • composer安装fxp插件时候提示内存不足且没有交换空间的解决办法

    The following exception is caused by a lack of memory and not having swap
    Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-for details

     http://www.linuxidc.com/Linux/2010-09/28915.htm ubuntu增加交换空间的步骤

    提供了创建交换空间的方法

    proc_open(): fork failed errors#

    If composer shows proc_open() fork failed on some commands:

    PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar

    This could be happening because the VPS runs out of memory and has no Swap space enabled.

    free -m
    
    total used free shared buffers cached
    Mem: 2048 357 1690 0 0 237
    -/+ buffers/cache: 119 1928
    Swap: 0 0 0

    To enable the swap you can use for example:

    /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
    /sbin/mkswap /var/swap.1
    /sbin/swapon /var/swap.1

    下面是整个过程
    root@tyr:/var/www/html/laravel# ./composer.phar global require "laravel/installer=~1.1"
    Changed current directory to /root/.composer
    PHP Fatal error:  Call to undefined method FxpComposerAssetPluginPackageVersionVersionParser::parseLinks() in /root/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 272
    
    Fatal error: Call to undefined method FxpComposerAssetPluginPackageVersionVersionParser::parseLinks() in /root/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 272
    root@tyr:/var/www/html/laravel# composer require "fxp/composer-asset-plugin:~1.0"
    ./composer.json has been created
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
      - Installing fxp/composer-asset-plugin (v1.0.3)
        Downloading: 100%         
    The following exception is caused by a lack of memory and not having swap configured
    Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details
    PHP Fatal error:  Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:974
    Stack trace:
    #0 [internal function]: ComposerUtilErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 974, Array)
    #1 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(974): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
    #2 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(784): SymfonyComponentConsoleApplication->getSttyColumns()
    #3 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(745): SymfonyComponentConsoleApplication->getTerminalDimensions()
    #4 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(675): SymfonyComponentConsoleApplication->getTerminalWidth()
    #5 phar:///usr/local/bin/com in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 974
    
    Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:974
    Stack trace:
    #0 [internal function]: ComposerUtilErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 974, Array)
    #1 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(974): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
    #2 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(784): SymfonyComponentConsoleApplication->getSttyColumns()
    #3 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(745): SymfonyComponentConsoleApplication->getTerminalDimensions()
    #4 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(675): SymfonyComponentConsoleApplication->getTerminalWidth()
    #5 phar:///usr/local/bin/com in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 974
    root@tyr:/var/www/html/laravel# free -m
                 total       used       free     shared    buffers     cached
    Mem:           488        414         74         24          1         71
    -/+ buffers/cache:        340        147
    Swap:            0          0          0
    root@tyr:/var/www/html/laravel# /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
    1024+0 records in
    1024+0 records out
    1073741824 bytes (1.1 GB) copied, 25.3413 s, 42.4 MB/s
    root@tyr:/var/www/html/laravel# /sbin/mkswap /var/swap.1
    Setting up swapspace version 1, size = 1048572 KiB
    no label, UUID=60a9b908-925a-4161-8fca-7ae2d5a76154
    root@tyr:/var/www/html/laravel# /sbin/swapon /var/swap.1
    root@tyr:/var/www/html/laravel# free -m
                 total       used       free     shared    buffers     cached
    Mem:           488        474         13         24          2        127
    -/+ buffers/cache:        344        143
    Swap:         1023          0       1023
    root@tyr:/var/www/html/laravel# composer require "fxp/composer-asset-plugin:~1.0"
    ./composer.json has been updated
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
      - Installing fxp/composer-asset-plugin (v1.0.3)
        Loading from cache
    
    Writing lock file
    Generating autoload files
    root@tyr:/var/www/html/laravel# 
     
  • 相关阅读:
    蚂蚁金服井贤栋:用技术联手金融机构,形成服务小微的生态合力
    蚂蚁金服 Service Mesh 渐进式迁移方案|Service Mesh Meetup 实录
    蚂蚁金服“定损宝”现身AI顶级会议NeurIPS
    报名 | 蚂蚁金服ATEC科技大会 · 上海:数字金融新原力
    前沿 | 中国中小银行都是如何展开数字化转型的?
    盘点:2018年双11背后的蚂蚁核心技术
    构筑敏捷能力中心,打造下一代数字银行“操作系统”!
    客户故事:4家银行如何打造新一代移动金融中心
    干货 | 金融级互联网产品持续交付的挑战与应对
    性能跃升50%!解密自主研发的金融级分布式关系数据库OceanBase 2.0
  • 原文地址:https://www.cnblogs.com/asworm/p/4886210.html
Copyright © 2011-2022 走看看