# 将插件添加到 app.yml 的格式问题

**URL:** https://meta.discourse.org/t/formatting-issues-adding-plugins-to-app-yml/307381
**Category:** Self-hosting
**Created:** [2024年五月5日 15:31 UTC](https://meta.discourse.org/t/formatting-issues-adding-plugins-to-app-yml/307381 "2024-05-05T15:31:01Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Master](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/master/32/383814_2.png) [@Master](https://meta.discourse.org/u/Master)
#### Post date: [2024年五月5日 15:31 UTC](https://meta.discourse.org/t/formatting-issues-adding-plugins-to-app-yml/307381/1 "2024-05-05T15:31:01Z")

</div>

您好，我从昨天开始就是 Discourse 用户，但使用提供的代码一直无法安装插件，因为它总是显示以下错误：

（未知）：在第 10 行第 1 列解析块映射时未找到预期的键 -e LANG=en\_US.UTF-8  
YAML 语法错误。请检查您的 containers/\*.yml 配置文件。

但是，我设法安装了至少 1 个插件，使用了第一个基础代码右侧的代码：

&& sudo -E -u discourse git clone [GitHub - discourse/discourse-solved: Allow accepted answers on topics](https://github.com/discourse/discourse-solved.git)

但是之后我无法再安装更多插件，因为该错误总是出现。

值得注意的是，我的安装是西班牙语的，我尝试将 en\_US 更改为 es\_ES，但问题也没有解决。

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [2024年五月5日 15:43 UTC](https://meta.discourse.org/t/formatting-issues-adding-plugins-to-app-yml/307381/2 "2024-05-05T15:43:19Z")

</div>

您能否分享一下您的 `after_code` 代码块的片段？yaml 对空格非常敏感，您可能不小心缩进了不该缩进的行。

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2024年五月5日 15:49 UTC](https://meta.discourse.org/t/formatting-issues-adding-plugins-to-app-yml/307381/3 "2024-05-05T15:49:06Z")

</div>

正如 Fireup 所建议的，请确保您没有为缩进添加或删除额外的空格。  
您可以使用类似 [https://yamlchecker.com/](https://yamlchecker.com/) 的工具来检查一切是否正确。 👍

---

<div class="post-metadata">

### Author: ![Master](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/master/32/383814_2.png) [@Master](https://meta.discourse.org/u/Master)
#### Post date: [2024年五月5日 15:51 UTC](https://meta.discourse.org/t/formatting-issues-adding-plugins-to-app-yml/307381/4 "2024-05-05T15:51:25Z")

</div>

此

 ![dc46cc47d1c3f32d8464af5657f94d3b](https://global.discourse-cdn.com/meta/original/4X/0/0/0/00081b7f78ebb02ddb032ae12e019300a5515e38.png)

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2024年五月5日 15:54 UTC](https://meta.discourse.org/t/formatting-issues-adding-plugins-to-app-yml/307381/5 "2024-05-05T15:54:35Z")

</div>

您的行应与上面一行的缩进级别相同。例如：

```plaintext
      cmd:
         - git clone...
         - git clone...

```

---

<div class="post-metadata">

### Author: ![Master](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/master/32/383814_2.png) [@Master](https://meta.discourse.org/u/Master)
#### Post date: [2024年五月5日 15:54 UTC](https://meta.discourse.org/t/formatting-issues-adding-plugins-to-app-yml/307381/6 "2024-05-05T15:54:51Z")

</div>

嘿朋友，非常感谢。有了那个网站，我解决了问题，那个网站以后绝对会是我的好朋友。😁

---

<div class="post-metadata">

### Author: ![Master](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/master/32/383814_2.png) [@Master](https://meta.discourse.org/u/Master)
#### Post date: [2024年五月5日 16:00 UTC](https://meta.discourse.org/t/formatting-issues-adding-plugins-to-app-yml/307381/7 "2024-05-05T16:00:13Z")

</div>

编译后，它在最后给了我这个错误

 ![屏幕截图 2024-05-05 115904](https://global.discourse-cdn.com/meta/original/4X/4/e/b/4eb5f908f5dbb02326a384d5848e49df0b23b4db.png)

---

<div class="post-metadata">

### Author: ![traceymoko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/traceymoko/32/483235_2.png) [@traceymoko](https://meta.discourse.org/u/traceymoko)
#### Post date: [2024年五月9日 10:25 UTC](https://meta.discourse.org/t/formatting-issues-adding-plugins-to-app-yml/307381/8 "2024-05-09T10:25:43Z")

</div>

> [@Master](#):
>
> 现在编译后，最后出现了这个错误
> 
> ![Captura de pantalla 2024-05-05 115904](https://global.discourse-cdn.com/meta/original/4X/4/e/b/4eb5f908f5dbb02326a384d5848e49df0b23b4db.png)

从您之前发布的这张图片来看：

> [@Master](#):
>
> 这个
> 
> ![dc46cc47d1c3f32d8464af5657f94d3b](https://global.discourse-cdn.com/meta/original/4X/0/0/0/00081b7f78ebb02ddb032ae12e019300a5515e38.png)

您还需要遵循第一个原始行的格式，如这里所述：

> [@techAPJ](#):
>
> 将插件的 `git clone` url 添加到包含 `git clone https://github.com/discourse/docker_manager.git` 的行下方。
> 
> 遵循 `docker_manager.git` 行现有的格式；如果它不包含 `sudo -E -u discourse`，则插入 `- git clone https://github.com/discourse/discourse-solved.git`。

所以您的可能需要看起来像这样：

```plaintext

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-akismet.git
          - git clone https://github.com/discourse/discourse-whos-online.git

```

---

<div class="post-metadata">

### Author: ![wal](https://avatars.discourse-cdn.com/v4/letter/w/d6d6ee/32.png) [@wal](https://meta.discourse.org/u/wal)
#### Post date: [2024年八月13日 04:18 UTC](https://meta.discourse.org/t/formatting-issues-adding-plugins-to-app-yml/307381/9 "2024-08-13T04:18:37Z")

</div>

只是想为这个话题补充一点，如果你正在使用 VS Code，我强烈推荐安装一个名为 `indent-rainbow` 的扩展

> 名称：indent-rainbow  
> ID：oderwat.indent-rainbow  
> 描述：使缩进更易于阅读  
> 版本：8.3.1  
> 发布者：oderwat  
> VS Marketplace 链接：[indent-rainbow - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=oderwat.indent-rainbow)

看起来像这样

 ![Screenshot 2024-08-13 at 12.16.00 AM](https://global.discourse-cdn.com/meta/original/4X/d/7/8/d781ba47d4533244d882a27ab2283e6d11c33e19.png)

这使得在 YAML 文件中查看缩进变得更加容易。在 VS Code 中，你也应该使用快捷键，如 Cmd + [或 Cmd +] 来增加或减少缩进。

哦，还忘了提一下，也要打开可见空格，那就是截图中可以看到的小灰点。
