运行composer install时出错执行\"'cache:clear --no-warmup'\"命令时出错:

Posted

技术标签:

【中文标题】运行composer install时出错执行\\"\'cache:clear --no-warmup\'\\"命令时出错:【英文标题】:Error when running composer install An error occurred when executing the \"'cache:clear --no-warmup'\" command:运行composer install时出错执行\"'cache:clear --no-warmup'\"命令时出错: 【发布时间】:2018-04-30 08:12:53 【问题描述】:

我正在尝试启动 Vagrant 机器(带有 ansible),它在执行“composer install”任务时抛出错误。我搜索了这个问题并尝试了多种不起作用的解决方案(如下所述)。

我认为这与无权写入应用程序/缓存和应用程序/日志的 vagrant 用户有关,即使我更改了 VM 和本地的权限。不知道修复是什么。

错误:

失败:[默认] (item=composer install) => "changed": true, "cmd": [“作曲家”,“安装”],“增量”:“0:00:06.144861”,“结束”:“2017-11-16 12:03:03.366269”,“失败”:真,“项目”:“作曲家安装”,“rc”:1, “开始”:“2017-11-16 12:02:57.221408”,“stderr”:“加载作曲家 包含包信息的存储库\n安装依赖项 (包括 require-dev) 来自锁定文件\n无需安装或 更新\n生成自动加载文件\n> Incenteev\ParameterHandler\ScriptHandler::buildParameters\n> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap\n> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache\nScript Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache 处理 symfony-scripts 事件因异常而终止\n\n \n [运行时异常] \n 执行 \"'cache:clear --no-warmup'\" 时出错 命令: \n // 使用 debug true 清除开发环境的缓存 \n \n [Symfony\组件\文件系统\异常\IOException] \n 删除目录失败 \"/var/www/fisher.dev/app/cache/de~/annotations\": . \n \n 缓存:清除 [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-s|--shell] [--process-isolation] [-e|--env ENV] [--no-debug] [--] \n . \n

Composer.json 文件:


"name": "fostermadeco/fisher",
"license": "proprietary",
"type": "project",
"autoload": 
    "psr-4": 
        "": "src/"
    ,
    "classmap": [
        "app/AppKernel.php",
        "app/AppCache.php"
    ]
,
"require": 
    "php": ">=5.3.9",
    "symfony/symfony": "2.8.*",
    "doctrine/orm": "^2.4.8",
    "doctrine/doctrine-bundle": "~1.4",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.11.3",
    "sensio/distribution-bundle": "~5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "snc/redis-bundle": "^2.0",
    "predis/predis": "^1.1",
    "doctrine/doctrine-migrations-bundle": "1.2.1",
    "alcaeus/mongo-php-adapter": "^1.0",
    "doctrine/mongodb-odm": "^1.2",
    "doctrine/mongodb-odm-bundle": "^3.2",
    "ocramius/package-versions": "^1.1",
    "ircmaxell/random-lib": "^1.2",
    "jms/serializer-bundle": "^1.1",
    "nelmio/api-doc-bundle": "^2.13",
    "maba/webpack-bundle": "^0.6.4",
    "stripe/stripe-php": "^4.3",
    "doctrine/annotations": "^1.3",
    "bugsnag/bugsnag-symfony": "^1.0",
    "stof/doctrine-extensions-bundle": "^1.2",
    "danielstjules/stringy": "^2.3",
    "doctrine/migrations": "1.4.1",
    "beberlei/DoctrineExtensions": "1.0.*"
,
"require-dev": 
    "sensio/generator-bundle": "~3.0",
    "symfony/phpunit-bridge": "~2.7",
    "doctrine/data-fixtures": "^1.2",
    "hautelook/alice-bundle": "^1.4"
,
"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": 
    "bin-dir": "bin"
,
"extra": 
    "symfony-app-dir": "app",
    "symfony-web-dir": "public",
    "symfony-assets-install": "relative",
    "incenteev-parameters": 
        "file": "app/config/parameters.yml"
    ,
    "branch-alias": null
,
"minimum-stability": "dev"

    我可以同时使用 'php app/console cache:clear' 和 'php app/console cache:clear --no-warmup' 来清除缓存

    我也可以 'rm -rf app/cache/*' 并且我已经更改了缓存文件夹 'sudo chmod -R 777 app/cache' 的权限

    我正在使用 ansible 设置 date.timezone='America/New_York'

任何帮助将不胜感激!谢谢!

【问题讨论】:

给我们composer.json文件 刚刚添加了composer.json文件 您是在本地运行composer install,还是也在虚拟机上运行? 我尝试在本地和虚拟机上运行。我收到一个错误 [Symfony\Component\Filesystem\Exception\IOException] 无法删除目录“/var/www/fisher.dev/app/cache/de~/annotations”:. 【参考方案1】:

我发现问题出在我的操作系统 macOS High Sierra v10.13.1 上。目前这个操作系统和 vagrant 存在一个 bug,这与 Vagrant 的文件同步、NFS 和 macOS 上的文件映射有关。

更多信息: http://www.qed42.com/blog/macos-sierra-issues-vagrant

【讨论】:

【参考方案2】:

问题似乎来自虚拟机如何处理映射路径。

从 VM 中更改项目目录中文件的所有权和权限不会出错 - 但经过进一步调查,您会发现所有权和权限实际上并未更改。

【讨论】:

我尝试在本地和虚拟机上运行“sudo chmod -R 777 app/cache”,但我仍然收到一个错误,它无法删除 /app/cache/de~/annotations 中的目录"

以上是关于运行composer install时出错执行\"'cache:clear --no-warmup'\"命令时出错:的主要内容,如果未能解决你的问题,请参考以下文章

为什么运行composer install --no-dev我在Barryvdh Debugbar ServiceProvider中出错?

yii2 composer install 出错的解决方法 php7.4

yii2 composer install 出错的解决方法 php7.4

composer install - 无法将您的要求解析为可安装的软件包集

尝试安装本机反应时出错,运行 pod install 时无法正确构建

IBM Cloud PHP 入门教程 - “php composer.phar install”出错