Symfony2 post-update-cmd给出“当生成引导程序文件时出现错误” [英] Symfony2 post-update-cmd gives "An error occurred when generating the bootstrap file"

查看:681
本文介绍了Symfony2 post-update-cmd给出“当生成引导程序文件时出现错误”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在Symfony2 2.3.7。
当我运行composer update命令时。在post-update-cmd中,运行脚本以更新symfony2。但它失败:

 脚本Sensio\Bundle \DistributionBundle\Composer\ScriptHandler :: buildBootstrap处理更新后-cmd事件以异常终止

[RuntimeException]
生成引导程序文件时出错。

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock]没有插件] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-dependencies] [-v | vv | vvv | --verbose] --optimize-autoloader] [packages1] ... [packagesN]


我试图运行:

  composer update --no-scripts 

..并且运行正常。以下也工作正常:

  php vendor / sensio / distribution-bundle / Sensio / Bundle / DistributionBundle / Resources / build_bootstrap.php 

但是每次我尝试正常的编辑器更新后脚本失败。
使用--verbose运行更新包含以下内容:

 脚本Sensio\Bundle \ DistributedBundle \Composer \ ScriptHandler :: buildBootstrap处理用异常终止的更新后cmd事件

[RuntimeException]
生成引导程序文件时出错。

异常跟踪:
()在C:\xampp\htdocs\forvaltning\vendor\sensio\distribution-bundle\Sensio\Bundle\DistributionBundle\\ \\Composer\ScriptHandler.php:203
Sensio\Bundle \DistributionBundle\Composer\ScriptHandler :: executeBuildBootstrap()at C:\ xampp\htdocs\forvaltning\vendor\sensio\\ \\ distribution-bundle\Sensio\Bundle\DistributionBundle\Composer\ScriptHandler.php:43
Sensio\Bundle \DistributionBundle\Composer\ScriptHandler :: buildBootstrap()at phar:// C:/ProgramData/Composer/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:165
Composer\EventDispatcher\EventDispatcher-> executeEventPhpScript()at phar:// C:/ ProgramData /Composer/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:138
Composer \EventDispatcher\EventDispatcher-> doDispatch()at phar:// C:/ ProgramData / Composer / bin /composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:107
Composer\EventDispatcher\EventDispatcher-> dispatchCommandEvent()at phar:// C:/ProgramData/Composer/bin/composer.phar /src/Composer/Installer.php:289
Composer\Installer-> run()at phar:// C:/ProgramData/Composer/bin/composer.phar/src/Composer/Command/UpdateCommand。 php:118
Composer \Command\UpdateCommand-> execute()at phar:// C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/ Command / Command.php:244
Symfony \Component\Console\Command\Command-> run()at phar:// C:/ProgramData/Composer/bin/composer.phar/vendor/ symfony / console / Symfony / Component / Console / Application.php:897
Symfony \Component\Console\Application-> doRunCommand()at phar:// C:/ ProgramData / Composer / bin / composer .phar / vendor / symfony / console / Symfony / Component / Console / Application.php:191
Symfony \Component\Console\Application-> doRun()at phar:// C:/ ProgramData / Composer / bin / composer.phar / src / Composer / Console / Application.php:117
Composer \Console\Application-> doRun()at phar:// C:/ ProgramData / Composer / bin / composer.phar / vendor / symfony / console / Symfony / Component / Console / Application.php:121
Symfony \Component\Console\Application-> run()at phar:// C:/ ProgramData /Composer/bin/composer.phar/src/Composer/Console/Application.php:83
Composer \Console\Application-> run()at phar:// C:/ ProgramData / Composer / bin /composer.phar/bin/composer:43
require()at C:\ProgramData\Composer\bin\composer.phar:15

update [--prefer- source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] --no-scripts] [--no-progress] [--with-dependencies] [-v | vv | vvv | --verbose] [-o | --optimize-autoloader] [packages1] ... [ ]

composer.json包含:

  {
name:symfony / framework-standard-edition,
license:MIT,
type:项目,
description:The \Symfony Standard Edition \distribution,
autoload:{
psr-0:{:src /}
},
repositories:[
{
type:package,
package:{
name :jquery / jquery,
version:1.9.1,
dist:{
url:http://code.jquery.com/ jquery-1.9.1.js,
type:file
}
}
}
]
php:> = 5.3.3,
symfony / symfony:2.3。*,
twig / extensions:1.0。* b $ bsymfony / assetic-bundle:2.3。*,
symfony / swiftmailer-bundle:2.3。*,
symfony / monolog-bundle: *,
sensio / distribution-bundle:2.3。*,
sensio / framework-extra-bundle:2.3。 bundle:2.3。*,
knplabs / knp-menu:2.0.*@dev,
leafo / lessphp:0.4.*@dev,
knplabs / knp-menu-bundle:2.0.*@dev,
incenteev / composer-parameter-handler:〜2.0,
twbs / bootstrap:2.3 。*,
jquery / jquery:1.9。*,
FortAwesome / Font-Awesome:3.2.1,
egeloen / ckeditor-bundle: 2. *
},
require-dev:{
phpunit / phpunit:3.7。*
},
scripts :{
post-install-cmd:[
Incenteev\\ParameterHandler\\ScriptHandler :: buildParameters,
Sensio\\Bundle \\\ \\ DistributionBundle \\Composer\\ ScriptHandler :: buildBootstrap,
Sensio\\Bundle\\ Distribution DistributionBundle \\Composer\\ ScriptHandler :: clearCache,
Sensio\\Bundle \\DistributionBundle\\Composer\\ ScriptHandler :: installAssets,
Sensio\\Bundle\\ DistributedBundle\\Composer \\ScriptHandler :: installRequirementsFile
],
post-update-cmd:[
Incenteev\\ParameterHandler\\ ScriptHandler :: buildParameters,
Sensio\\Bundle\\DistributionBundle\\Composer\\ ScriptHandler :: buildBootstrap,
Sensio\\Bundle \\ DistributionionBundle \\ Composer \\\ScriptScriptHandler :: clearCache,
Sensio\\Bundle\\ DistributedBundle\\Composer\\ScriptHandler :: installAssets,
Sensio\ \Bundle\\DistributionBundle\\Composer\\ScriptHandler :: installRequirementsFile
]
},
config:{
bin-dir :bin
},
minimum-stability:stable,
extra:{
symfony-app-dir
symfony-web-dir:web,
incenteev-parameters:{
file:app / config / parameters.yml
}
branch-alias:{
dev-master:2.3-dev
}
}

}

解决方案

如何解决安装/更新Symfony 2问题



最常见的解决方案:




  • 移除 / bin / vendor 文件夹。

  • 创建

  • 如果您没有安装作曲家,请安装(或 php composer.phar install >它应该可以工作了!有关详细信息: Symfony安装
  • 如果您仍然遇到此错误:« 生成引导程序文件时出错»

    这意味着您有文件权限问题。请参阅以下过程以解决问题


设置或修复文件权限:



在终端中执行以下命令:




  • rm -rf app / cache / *

  • rm -rf app / logs / *



在macOS 系统上,chmod命令支持 + a 标志来定义ACL。使用以下脚本确定您的网络服务器用户并授予所需的权限:




  • HTTPDUSER =`ps axo用户,comm | grep -E'[a] pache | [h] ttpd | [_] www | [w] ww-data | [n] ginx'| grep -v root |头-1 | cut -d\ -f1`

  • sudo chmod + a$ HTTPDUSER allow delete,write,append,file_inherit,directory_inherit app / cache app / logs

  • sudo chmod + a`whoami` allow delete,write,append,file_inherit,directory_inherit / cache> / cache> / cache> / 在大多数Linux和BSD t支持 chmod + a ,但是支持另一个名为 setfacl 的实用程序。您可能需要安装 setfacl 启用ACL支持 a>在磁盘分区上使用它之前。然后,使用以下脚本确定您的Web服务器用户并授予所需的权限:




    • HTTPDUSER =`ps axo user,comm | grep -E'[a] pache | [h] ttpd | [_] www | [w] ww-data | [n] ginx'| grep -v root |头-1 | cut -d\ -f1`

      如果这不起作用,请尝试添加 -n

    • sudo setfacl -R -mu:$ HTTPDUSER:rwX -mu:`whoami`:rwX app / cache app / logs

    • sudo setfacl -dR -mu:$ HTTPDUSER:rwX -mu:`whoami`:rwX app / cache app / logs



    如果上述方法都不适用于您



    更改umask ,以便缓存和日志目录是可组写的或全局写的(取决于Web服务器用户和命令行用户是否在同一组中)。为了实现这一点,将以下行放在 app / console web / app.php code> web / app_dev.php 档案:



    umask(0002) //这将允许权限为0775



    umask(0000); //这将允许权限为0777


    有关更多信息,请参阅官方文档: Symfony文件权限



    I am currently on Symfony2 2.3.7. When I run the composer update command. In the post-update-cmd a script is run to update symfony2. But it fails:

    Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap handling the post-update-cmd event terminated with an exception
    
      [RuntimeException]                                     
      An error occurred when generating the bootstrap file.  
    
    update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [packagesN]
    

    Any idea why this is happening? I tried to run:

    composer update --no-scripts 
    

    .. and that runs fine. The following is also working fine:

    php vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
    

    But everytime I try the normal composer update the post script fails. Running the update with --verbose gives the following:

    Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap handling the post-update-cmd event terminated with an exception
    
      [RuntimeException]                                     
      An error occurred when generating the bootstrap file.                                                      
    
    Exception trace:
     () at C:\xampp\htdocs\forvaltning\vendor\sensio\distribution-bundle\Sensio\Bundle\DistributionBundle\Composer\ScriptHandler.php:203
     Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::executeBuildBootstrap() at C:\xampp\htdocs\forvaltning\vendor\sensio\distribution-bundle\Sensio\Bundle\DistributionBundle\Composer\ScriptHandler.php:43
     Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:165
     Composer\EventDispatcher\EventDispatcher->executeEventPhpScript() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:138
     Composer\EventDispatcher\EventDispatcher->doDispatch() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:107
     Composer\EventDispatcher\EventDispatcher->dispatchCommandEvent() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer.php:289
     Composer\Installer->run() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Command/UpdateCommand.php:118
     Composer\Command\UpdateCommand->execute() at phar://C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
     Symfony\Component\Console\Command\Command->run() at phar://C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:897
     Symfony\Component\Console\Application->doRunCommand() at phar://C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:191
     Symfony\Component\Console\Application->doRun() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Console/Application.php:117
     Composer\Console\Application->doRun() at phar://C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:121
     Symfony\Component\Console\Application->run() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Console/Application.php:83
     Composer\Console\Application->run() at phar://C:/ProgramData/Composer/bin/composer.phar/bin/composer:43
     require() at C:\ProgramData\Composer\bin\composer.phar:15
    
    update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [packagesN]
    

    The composer.json contains:

    {
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "jquery/jquery",
                "version": "1.9.1",
                "dist": {
                    "url": "http://code.jquery.com/jquery-1.9.1.js",
                    "type": "file"
                }
            }
        }
    ],
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.3.*",
        "twig/extensions": "1.0.*",
        "symfony/assetic-bundle": "2.3.*",
        "symfony/swiftmailer-bundle": "2.3.*",
        "symfony/monolog-bundle": "2.3.*",
        "sensio/distribution-bundle": "2.3.*",
        "sensio/framework-extra-bundle": "2.3.*",
        "sensio/generator-bundle": "2.3.*",
        "knplabs/knp-menu": "2.0.*@dev",
        "leafo/lessphp": "0.4.*@dev",
        "knplabs/knp-menu-bundle": "2.0.*@dev",
        "incenteev/composer-parameter-handler": "~2.0",
        "twbs/bootstrap": "2.3.*",
        "jquery/jquery": "1.9.*",
        "FortAwesome/Font-Awesome": "3.2.1",
        "egeloen/ckeditor-bundle": "2.*"
    },
    "require-dev": {
        "phpunit/phpunit": "3.7.*"
    },
    "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"
        ],
        "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"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "minimum-stability": "stable",
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.3-dev"
        }
    }
    

    }

    解决方案

    How to solve install/update Symfony 2 issues

    The most common solution :

    • Remove the /bin and /vendor folders of your project.
    • Make a composer install (or php composer.phar install if your didn't install composer).
    • It should work now! For more informations : Symfony installation.
    • If you still have this error : «An error occurred when generating the bootstrap file»
      It means that you have file permission issue. See below procedure for solve the problem

    Setting up or Fixing File Permissions :

    In a terminal execute following commands :

    • rm -rf app/cache/*
    • rm -rf app/logs/*

    On macOS systems, the chmod command supports the +a flag to define an ACL. Use the following script to determine your web server user and grant the needed permissions:

    • HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
    • sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
    • sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs

    On most Linux and BSD distributions don't support chmod +a, but do support another utility called setfacl. You may need to install setfacl and enable ACL support on your disk partition before using it. Then, use the following script to determine your web server user and grant the needed permissions:

    • HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
      if this doesn't work, try adding -n option
    • sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
    • sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs

    If none of the previous methods work for you

    Change the umask so that the cache and log directories are group-writable or world-writable (depending if the web server user and the command line user are in the same group or not). To achieve this, put the following line at the beginning of the app/console, web/app.php and web/app_dev.php files:

    umask(0002); // This will let the permissions be 0775
    or
    umask(0000); // This will let the permissions be 0777

    For more information see official documentation : Symfony file permissions

    这篇关于Symfony2 post-update-cmd给出“当生成引导程序文件时出现错误”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆