# Bootstrap 错误与 ai plugin，bundle exec rake db:migrate

**URL:** https://meta.discourse.org/t/bootstrap-error-with-ai-plugin-bundle-exec-rake-db-migrate/371514
**Category:** Support
**Tags:** ai
**Created:** [2025年六月24日 16:12 UTC](https://meta.discourse.org/t/bootstrap-error-with-ai-plugin-bundle-exec-rake-db-migrate/371514 "2025-06-24T16:12:40Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Thomas\_Rother](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thomas_rother/32/423597_2.png) [@Thomas\_Rother](https://meta.discourse.org/u/Thomas_Rother)
#### Post date: [2025年六月24日 16:12 UTC](https://meta.discourse.org/t/bootstrap-error-with-ai-plugin-bundle-exec-rake-db-migrate/371514/1 "2025-06-24T16:12:40Z")

</div>

我当前使用的 3.5.0.beta7-dev 版本，在 web\_only 容器设置中加入 AI 插件后，立即遇到了一个 bootstrap 错误。 **不** 包含此插件时，相同的构建可以正常工作。

通过阅读 [https://meta.discourse.org/t/upgrade-error-rake-db-migrate-index-on-theme-field-id/278935/7，我怀疑根本原因是（外部）Postgres](https://meta.discourse.org/t/upgrade-error-rake-db-migrate-index-on-theme-field-id/278935/7%EF%BC%8C%E6%88%91%E6%80%80%E7%96%91%E6%A0%B9%E6%9C%AC%E5%8E%9F%E5%9B%A0%E6%98%AF%EF%BC%88%E5%A4%96%E9%83%A8%EF%BC%89Postgres) 服务器 13.20 缺少一个扩展。该服务器具有 **hstore, pg\_trgm, plpgsql, unaccent** 扩展，并且也用于生产环境的 Discourse 安装，该安装使用相同的代码，但尚未包含 AI 插件。

**有人能确定 AI 插件所需的 Postgres 扩展吗？** 我在 [Discourse AI - Self-Hosted Guide](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598) 中找不到此信息。类似的错误帖子，例如 [AI Plugin Build Error - 'bundle exec rake db:migrate' failed](https://meta.discourse.org/t/ai-plugin-build-error-bundle-exec-rake-db-migrate-failed/288104?u=thomas_rother%EF%BC%8C%E4%BD%BF%E7%94%A8%E4%BA%86%E4%B8%8D%E5%90%8C%E7%9A%84%E5%9C%BA%E6%99%AF%EF%BC%8C%E5%8F%AF%E8%83%BD%E4%B8%8E%E6%88%91%E8%BF%99%E9%87%8C%E7%9A%84%E5%AE%9E%E9%99%85%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF%E6%97%A0%E5%85%B3%E2%80%A6%E2%80%A6)

web\_only.yaml 的相关部分

```plaintext
templates:
 - "templates/web.template.yml"
 ## Uncomment the next line to enable the IPv6 listener
 #- "templates/web.ipv6.template.yml"
 - "templates/web.ratelimited.template.yml"
 - "templates/web.socketed.template.yml"
 ## Uncomment these two lines if you wish to add Lets Encrypt (https)
 #- "templates/web.ssl.template.yml"
 #- "templates/web.letsencrypt.ssl.template.yml"

[...]

## configure connectivity to the databases
 DISCOURSE_DB_SOCKET: ''
 DISCOURSE_DB_USERNAME: discourse2
 DISCOURSE_DB_NAME: discourse2
 DISCOURSE_DB_PASSWORD: xxx
 DISCOURSE_DB_HOST: 10.10.10.xx
# redis caching on the neighbouring container
 DISCOURSE_REDIS_HOST: redis

[...]

## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
 after_code:
   - exec:
       cd: $home/plugins
       cmd:
         - git clone https://github.com/discourse/docker_manager.git
         - git clone https://github.com/discourse/discourse-shared-edits.git
         - git clone https://github.com/discourse/discourse-chat-integration.git
         - git clone https://github.com/discourse/discourse-openid-connect.git
         - git clone https://github.com/discourse/discourse-calendar.git
         - git clone https://github.com/angusmcleod/discourse-events.git
         - git clone https://github.com/discourse/discourse-data-explorer.git
         - git clone https://github.com/discourse/discourse-reactions.git
         - git clone https://github.com/discourse/discourse-chat.git
         - git clone https://github.com/discourse/discourse-ai.git
         - git clone https://github.com/discourse/discourse-topic-voting.git
         - git clone https://github.com/discourse/discourse-post-voting.git
         - git clone https://github.com/discourse/discourse-user-notes.git
         - git clone https://github.com/discourse/discourse-solved.git
         - git clone https://github.com/discourse/discourse-docs-card-filter.git
         - git clone https://github.com/discourse/discourse-doc-categories.git
         - git clone https://github.com/discourse/discourse-assign.git
         - git clone https://github.com/discourse/discourse-templates.git
         - git clone https://github.com/discourse/discourse-saved-searches.git
         - git clone https://github.com/discourse/discourse-tooltips.git
         - git clone https://github.com/discourse/discourse-category-experts.git
         - git clone https://github.com/discourse/discourse-activity-pub.git
         - git clone https://github.com/discourse/discourse-follow.git
         - git clone https://github.com/nathan-nz/discourse-wikified-posts.git
         - git clone https://github.com/discourse/discourse-whos-online.git
         - git clone https://github.com/merefield/discourse-workflow.git
[...]

## for operation behind haproxy load balancer with local nginx on the container host
 - replace:
     filename: /etc/nginx/conf.d/discourse.conf
     from: "types {"
     to: |
       set_real_ip_from 127.0.0.1/24;
       set_real_ip_from 10.0.0.0/24;
       real_ip_header X-Forwarded-For;
       real_ip_recursive on;
       proxy_set_header Host $http_host;
       proxy_set_header X-Request-Start “t=${msec}”;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto https; # replaced $thescheme;
       proxy_set_header X-Real-IP $remote_addr;
       types {
[...]

```

sudo docker logs -t --tail 1000 web\_only

```plaintext
gem install ice_cube -v 0.16.4 -i /var/www/discourse/plugins/discourse-events/gems/3.3.6 --no-document --ignore-dependencies --no-user-install
Successfully installed ice_cube-0.16.4
1 gem installed
gem install icalendar -v 2.8.0 -i /var/www/discourse/plugins/discourse-events/gems/3.3.6 --no-document --ignore-dependencies --no-user-install
ActiveSupport is required for TimeWithZone support, but not required for general use.
Successfully installed icalendar-2.8.0
1 gem installed
gem install icalendar-recurrence -v 1.1.3 -i /var/www/discourse/plugins/discourse-events/gems/3.3.6 --no-document --ignore-dependencies --no-user-install
Successfully installed icalendar-recurrence-1.1.3
1 gem installed
gem install multipart-post -v 2.4.0 -i /var/www/discourse/plugins/discourse-workflow/gems/3.3.6 --no-document --ignore-dependencies --no-user-install
Successfully installed multipart-post-2.4.0
1 gem installed
gem install faraday-multipart -v 1.0.4 -i /var/www/discourse/plugins/discourse-workflow/gems/3.3.6 --no-document --ignore-dependencies --no-user-install
Successfully installed faraday-multipart-1.0.4
1 gem installed
gem install event_stream_parser -v 1.0.0 -i /var/www/discourse/plugins/discourse-workflow/gems/3.3.6 --no-document --ignore-dependencies --no-user-install
Successfully installed event_stream_parser-1.0.0
1 gem installed
gem install ruby-openai -v 8.1.0 -i /var/www/discourse/plugins/discourse-workflow/gems/3.3.6 --no-document --ignore-dependencies --no-user-install
Successfully installed ruby-openai-8.1.0
1 gem installed
== 20230710171141 EnablePgVectorExtension: migrating ==========================
-- enable_extension(:vector)

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse &amp;&amp; su discourse -c 'bundle exec rake db:migrate' failed with return #&lt;Process::Status: pid 3914 exit 1&gt;
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "tag"=>"migrate", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
**FAILED TO BOOTSTRAP** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
3fac1371a3dd8b0d59760e492965c1d7ebb8a09e99549a9483596453f95ce871

```

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2025年六月24日 16:22 UTC](https://meta.discourse.org/t/bootstrap-error-with-ai-plugin-bundle-exec-rake-db-migrate/371514/2 "2025-06-24T16:22:28Z")

</div>

> [@Thomas\_Rother](#):
>
> 有人能确定AI插件所需的postgres扩展吗？

您需要 [GitHub - pgvector/pgvector: Open-source vector similarity search for Postgres](https://github.com/pgvector/pgvector)

> <https://github.com/discourse/discourse_docker/blob/main/templates/postgres.template.yml#L253-L256>

---

<div class="post-metadata">

### Author: ![Thomas\_Rother](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thomas_rother/32/423597_2.png) [@Thomas\_Rother](https://meta.discourse.org/u/Thomas_Rother)
#### Post date: [2025年六月24日 17:04 UTC](https://meta.discourse.org/t/bootstrap-error-with-ai-plugin-bundle-exec-rake-db-migrate/371514/3 "2025-06-24T17:04:29Z")

</div>

> [@Falco](#):
>
> `create extension if not exists vector;`

是的，谢谢，就是这个，引导现在成功了。也许应该将此信息添加到 AI 自托管指南中……

---

<div class="post-metadata">

### Author: ![zabin](https://avatars.discourse-cdn.com/v4/letter/z/58f4c7/32.png) [@zabin](https://meta.discourse.org/u/zabin)
#### Post date: [2025年七月10日 19:06 UTC](https://meta.discourse.org/t/bootstrap-error-with-ai-plugin-bundle-exec-rake-db-migrate/371514/4 "2025-07-10T19:06:08Z")

</div>

> [@Thomas\_Rother](#):
>
> ccessful. Maybe this info

我曾认为该插件应该在迁移过程中执行此基本步骤。令我惊讶的是，这需要用户来运行。不幸的是，我们使用的是 bitnami chart，我无法通过 chart 控制此扩展的运行。我宁愿不手动执行，但看起来这是唯一的途径。

我想了解为什么该插件不在其迁移脚本中添加它？是否有特定原因？

---

<div class="post-metadata">

### Author: ![Thomas\_Rother](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thomas_rother/32/423597_2.png) [@Thomas\_Rother](https://meta.discourse.org/u/Thomas_Rother)
#### Post date: [2025年七月10日 19:32 UTC](https://meta.discourse.org/t/bootstrap-error-with-ai-plugin-bundle-exec-rake-db-migrate/371514/5 "2025-07-10T19:32:25Z")

</div>

在我的情况下，Discourse 的数据库部分位于一个外部服务器上，而不是 Discourse 容器的标准捆绑包的一部分。vector 扩展必须以与 Discourse 的数据库用户不同的权限进行安装。因此，安装必须手动执行，而不是引导过程中的一个步骤。

---

<div class="post-metadata">

### Author: ![zabin](https://avatars.discourse-cdn.com/v4/letter/z/58f4c7/32.png) [@zabin](https://meta.discourse.org/u/zabin)
#### Post date: [2025年七月23日 13:26 UTC](https://meta.discourse.org/t/bootstrap-error-with-ai-plugin-bundle-exec-rake-db-migrate/371514/6 "2025-07-23T13:26:30Z")

</div>

这是真的。以下是我成功的方法。

- 使用 bitnami discourse chart
- 覆盖 bitnami postgres 的 dockerfile 并以 root 身份安装 vector
- 在 postgres 启动时运行一个初始化脚本，使 `discourse` 用户成为 vector 的所有者
- 其余部分（包括插件安装）由 bitnami chart 处理

我为此付出了沉重的代价。我希望有一些文档说明这一点。插件文档应该提到一些先决条件。

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2025年八月22日 13:27 UTC](https://meta.discourse.org/t/bootstrap-error-with-ai-plugin-bundle-exec-rake-db-migrate/371514/7 "2025-08-22T13:27:28Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
