错误代码 1 缓存:在作曲家需要时清除 [英] error code 1 cache:clear during composer require

查看:28
本文介绍了错误代码 1 缓存:在作曲家需要时清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法按照 github 示例安装/要求 ongr/elasticsearch-bundle~5.0".

Can't install/require the ongr/elasticsearch-bundle "~5.0" as per github example.

我正在全新安装最新的 symfony.

Im running a fresh install of the latest symfony.

我正在运行以下命令:作曲家需要 ongr/elasticsearch-bundle "~5.0"

I'm running the following command: composer require ongr/elasticsearch-bundle "~5.0"

根据 https://github.com/ongr-io/ElasticsearchBundle

composer require ongr/elasticsearch-bundle "~5.0"

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.2.*"
Package operations: 7 installs, 0 updates, 0 removals
  - Installing react/promise (v2.7.1): Loading from cache
  - Installing guzzlehttp/streams (3.0.0): Loading from cache
  - Installing guzzlehttp/ringphp (1.1.1): Loading from cache
  - Installing elasticsearch/elasticsearch (v5.5.0): Loading from cache
  - Installing ongr/elasticsearch-dsl (v5.0.6): Loading from cache
  - Installing symfony/templating (v4.2.11): Loading from cache
  - Installing ongr/elasticsearch-bundle (v5.2.4): Loading from cache
Writing lock file
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
Symfony operations: 1 recipe (c91982d16a3859d0a43fd4ff85aa437a)
  - Configuring ongr/elasticsearch-bundle (>=v5.2.4): From auto-generated recipe
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!  
!!  In ArrayNode.php line 228:
!!                                                                                
!!    The child node "managers" at path "ongr_elasticsearch" must be configured.  
!!                                                                                
!!  
!!  
Script @auto-scripts was called via post-update-cmd

Installation failed, reverting ./composer.json to its original content.

我该怎么做才能解决这个问题?

What can I do to solve this issue?

本教程提到了一个 config.yml(我没有),我认为如果在安装过程中不存在它会被创建

The tutorial mentions a config.yml (which i dont have), i'd assume this would be created if it doesnt exist during the installation

推荐答案

问题是有一个脚本会在安装新的依赖项后立即清除 Symfony 缓存,然后才有机会向配置文件添加适当的配置.

The problem is that there's a script that clears Symfony cache immediately after the new dependencies are installed, before you get the chance to add proper configuration to your config files.

假设您的 composer.json 文件中有一个如下所示的部分:

Assuming there's a section in your composer.json file that looks like this:

"scripts": {
    "auto-scripts": {
        "cache:clear": "symfony-cmd",
        "assets:install %PUBLIC_DIR%": "symfony-cmd"
    },

您应该删除 "cache:clear": "symfony-cmd" 行.如果它看起来不完全像这样,只需删除所有包含 cache:clear 的行.您可能希望在成功安装和配置 ongr/elasticsearch-bundle 后恢复这一行/这些行,这样您就不必记住在安装更好的捆绑包后手动清除缓存与 Symfony Flex 兼容,或者不要因为它过于热衷于提供帮助而成为受害者.

you should remove the "cache:clear": "symfony-cmd" line. If it doesn't look exactly like this, just remove all lines that contain cache:clear. You might want to restore this line/these lines after you've successfully installed and configured ongr/elasticsearch-bundle, so that you don't have to remember to clear cache manually after installing bundles that are better compatible with Symfony Flex, or don't fall victim to its overzealousness with trying to be helpful.

或者,这可能是一个更好的解决方案 - 完全摆脱 symfony/flex.当某些 3rd 方在没有检查是否满足所有要求的情况下向配方添加命令时,它有一个令人讨厌的习惯,即弄乱您的配置文件.我知道,我去过那里.

Alternatively, and this is probably a much better solution - get rid of symfony/flex entirely. It has a nasty habit of messing up your configuration files when some 3rd party adds a command to a recipe without checking if all the requirements have been met. I know, I've been there.

这篇关于错误代码 1 缓存:在作曲家需要时清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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