AWS VM 中 Capistrano 和 Symfony 3.3 的问题 Composer `Memory limit`

Posted

技术标签:

【中文标题】AWS VM 中 Capistrano 和 Symfony 3.3 的问题 Composer `Memory limit`【英文标题】:Problem Composer `Memory limit` with Capistrano and Symfony 3.3 in AWS VM 【发布时间】:2018-11-21 10:50:24 【问题描述】:

当我启动我的命令时,我的作曲家和 capistrano 有问题:

Problem 1
    - Installation request for symfony/symfony v3.3.17 -> satisfiable by symfony/symfony[v3.3.17].
    - don't install symfony/var-dumper v4.0.12|don't install symfony/symfony v3.3.17
    - Installation request for symfony/var-dumper v4.0.12 -> satisfiable by symfony/var-dumper[v4.0.12].

这是我的 composer.json :


  "name": "mickaelmonsang/showroom",
  "license": "proprietary",
  "type": "project",
  "autoload": 
    "psr-4": 
      "AppBundle\\": "src/AppBundle"
    ,
    "classmap": [
      "app/AppKernel.php",
      "app/AppCache.php"
    ]
  ,
  "autoload-dev": 
    "psr-4": 
      "Tests\\": "tests/"
    ,
    "files": [
      "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
    ]
  ,
  "require": 
    "php": ">=5.5.9",
    "cocur/slugify": "^3.1",
    "composer/ca-bundle": "^1.1",
    "doctrine/annotations": "^1.6",
    "doctrine/cache": "^1.7",
    "doctrine/doctrine-bundle": "^1.9",
    "doctrine/doctrine-cache-bundle": "^1.3",
    "doctrine/doctrine-migrations-bundle": "^1.0",
    "doctrine/inflector": "^1.3",
    "doctrine/migrations": "^1.8",
    "doctrine/orm": "^2.5",
    "doctrine/reflection": "^1.0",
    "friendsofsymfony/user-bundle": "^2.1",
    "gedmo/doctrine-extensions": "^2.4",
    "guzzlehttp/guzzle": "^6.3",
    "hwi/oauth-bundle": "^0.5.3",
    "incenteev/composer-parameter-handler": "^2.1",
    "knplabs/gaufrette": "^0.6.0",
    "knplabs/knp-components": "^1.3",
    "knplabs/knp-gaufrette-bundle": "^0.5.3",
    "knplabs/knp-menu": "^2.3",
    "knplabs/knp-menu-bundle": "^2.2",
    "knplabs/knp-paginator-bundle": "^2.8",
    "kriswallsmith/buzz": "0.16.1",
    "league/oauth2-client": "^2.3",
    "ocramius/package-versions": "^1.3",
    "paragonie/random_compat": "2.0.17",
    "psr/simple-cache": "^1.0",
    "sensio/distribution-bundle": "^5.0",
    "sensio/framework-extra-bundle": "3.0.29",
    "sensio/generator-bundle": "^3.1",
    "sensiolabs/security-checker": "^4.1",
    "sonata-project/admin-bundle": "3.36.0",
    "sonata-project/block-bundle": "^3.12",
    "sonata-project/cache": "^2.0",
    "sonata-project/core-bundle": "^3.11",
    "sonata-project/datagrid-bundle": "^2.3",
    "sonata-project/doctrine-orm-admin-bundle": "3.6.1",
    "sonata-project/exporter": "^1.9",
    "stof/doctrine-extensions-bundle": "^1.3",
    "swiftmailer/swiftmailer": "5.4.9",
    "symfony/assetic-bundle": "^2.8",
    "symfony/monolog-bundle": "3.2.0",
    "symfony/phpunit-bridge": "^4.1",
    "symfony/polyfill-apcu": "^1.8",
    "symfony/polyfill-intl-icu": "^1.8",
    "symfony/polyfill-mbstring": "^1.8",
    "symfony/polyfill-php56": "^1.8",
    "symfony/polyfill-php70": "^1.8",
    "symfony/polyfill-php72": "^1.8",
    "symfony/polyfill-util": "^1.8",
    "symfony/security-acl": "3.0.1",
    "symfony/swiftmailer-bundle": "2.6.7",
    "symfony/symfony": "3.3.17",
    "symfony/var-dumper": "4.0.12",
    "twig/twig": "^2.5",
    "vich/uploader-bundle": "1.7.1",
    "zendframework/zend-eventmanager": "^3.2"
  ,
  "require-dev": 
  ,
  "scripts": 
    "symfony-scripts": [
      "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",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ],
    "post-install-cmd": [
      "@symfony-scripts"
    ],
    "post-update-cmd": [
      "@symfony-scripts"
    ]
  ,
  "config": 
    "sort-packages": true
  ,
  "extra": 
    "symfony-app-dir": "app",
    "symfony-bin-dir": "bin",
    "symfony-var-dir": "var",
    "symfony-web-dir": "web",
    "symfony-tests-dir": "tests",
    "symfony-assets-install": "relative",
    "incenteev-parameters": 
      "file": "app/config/parameters.yml"
    ,
    "branch-alias": null
  

当我想用 composer 安装任何包时,我遇到了一个错误:

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 343932928) (tried to allocate 1560576 bytes)

或者我已经将 PHP memory_limit 设置为 -1 并重新启动。

怎么了?

注意:我使用的是 PHP7.0

希望你有解决方案:)。

【问题讨论】:

【参考方案1】:

symfony/symfony 软件包已包含 VarDumper 组件(您尝试使用 symfony/var-dumper 软件包安装该组件)。这是 Composer 在旧版本中错误允许的内容,在 Composer 1.7.3 中已修复。

您真的需要版本 4 中的 VarDumper 组件吗?如果是这种情况,您需要先删除symfony/symfony,如果您无法将所有 Symfony 软件包升级到 4,则需要明确要求所有需要的组件。

【讨论】:

感谢您的回答,非常有帮助【参考方案2】:

既有短期解决方案,也有长期解决方案,

短期:粘贴到您的 php 文件中。

ini_set('memory_limit', '256M');

长期:php.ini文件中的默认值更改为以下。

memory_limit = 256M

有关此问题的更多信息,take a look at this thread here.

【讨论】:

你好,我已经将我的 memory_limit 设置为 256Mo,但这并不能解决我的问题

以上是关于AWS VM 中 Capistrano 和 Symfony 3.3 的问题 Composer `Memory limit`的主要内容,如果未能解决你的问题,请参考以下文章

AWS ElasticBeanstalk、CodeDeploy 与 Capistrano、Mina、Vlad 等

使用 Capistrano 将 Ruby on Rails 应用程序部署到 Windows Azure VM 时出现超时错误

Rails 4 + Capistrano + AWS Net::SSH::AuthenticationFailed: 部署

在AWS上使用Capistrano的Rails secrets.yml VS Dotenv VS Figaro

AWS Storage Gateway VM登陆账号密码

检测 VM 中的云类型