构建失败

刚才构建时,遇到下面的错误:

[log] <DIR>/assets/js/chunk-kzds8qh6.digested.js                         chunk │ size:   297.19 kB
[log] <DIR>/assets/js/chunk-b1q66eup.digested.js                         chunk │ size:   358.64 kB
[log] <DIR>/assets/js/jspreadsheet-c0a3yubd.digested.js                  chunk │ size:   475.17 kB
[log] <DIR>/assets/js/codemirror-editor-fo821emj.digested.js             chunk │ size:   498.87 kB
[log] <DIR>/assets/js/chunk-enbilv94.digested.js                         chunk │ size:   506.45 kB
[log] <DIR>/assets/js/jsoneditor-dmbb2ak0.digested.js                    chunk │ size:   530.72 kB
[log] <DIR>/assets/js/ace-editor-bundle-bd9fwf91.digested.js             chunk │ size:   612.67 kB
[log] <DIR>/assets/js/full-calendar-bundle-fr7dwh7s.digested.js          chunk │ size:   992.27 kB
[log] <DIR>/assets/js/admin-c45bp8xv.digested.js                         chunk │ size: 1,343.19 kB
[log] <DIR>/assets/js/faker-o7ara9hb.digested.js                         chunk │ size: 2,321.90 kB
[log] <DIR>/assets/js/discourse-kovviugm.digested.js                     chunk │ size: 3,577.22 kB
[log]
[success] rolldown v1.1.2 Finished in 18.40 s
/var/www/discourse/plugins/discourse-ai/lib/tasks/create_topics.rake:51: warning: already initialized constant TopicGenerator::FIRST_POST_RESPONSE_FORMAT
/var/www/discourse/plugins/discourse-ai/lib/tasks/create_topics.rake:51: warning: previous definition of FIRST_POST_RESPONSE_FORMAT was here
/var/www/discourse/plugins/discourse-ai/lib/tasks/create_topics.rake:69: warning: already initialized constant TopicGenerator::REPLIES_RESPONSE_FORMAT
/var/www/discourse/plugins/discourse-ai/lib/tasks/create_topics.rake:69: warning: previous definition of REPLIES_RESPONSE_FORMAT was here
Compiling 49 plugins...
Finished initial compilation of plugins in 33.75s
rake aborted!
Don't know how to build task 'assets:precompile:pretty_text' (See the list of available tasks with `rake --tasks`)
Did you mean?  assets:precompile
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/rake-13.4.2/exe/rake:27:in '<top (required)>'
/usr/local/bin/bundle:25:in 'Kernel#load'
/usr/local/bin/bundle:25:in '<main>'
(See full trace by running task with --trace)
I, [2026-09-07T07:06:45.573543 #1]  INFO -- : Terminating async processes
I, [2026-09-07T07:06:45.619547 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/18/bin/postgres -D /etc/postgresql/18/main pid: 45
I, [2026-09-07T07:06:45.621006 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 128
128:signal-handler (1788764805) Received SIGTERM scheduling shutdown...
2026-09-07 07:06:45.621 UTC [45] LOG:  received fast shutdown request
2026-09-07 07:06:45.628 UTC [45] LOG:  aborting any active transactions
128:M 07 Sep 2026 07:06:45.638 * User requested shutdown...
128:M 07 Sep 2026 07:06:45.639 * Saving the final RDB snapshot before exiting.
2026-09-07 07:06:45.661 UTC [45] LOG:  background worker "logical replication launcher" (PID 62) exited with exit code 1
2026-09-07 07:06:45.679 UTC [57] LOG:  shutting down
2026-09-07 07:06:45.685 UTC [57] LOG:  checkpoint starting: shutdown immediate
128:M 07 Sep 2026 07:06:46.044 * DB saved on disk
128:M 07 Sep 2026 07:06:46.044 # Redis is now ready to exit, bye bye...
2026-09-07 07:06:46.063 UTC [57] LOG:  checkpoint complete: wrote 56 buffers (0.1%), wrote 3 SLRU buffers; 0 WAL file(s) added, 0 removed, 0 recycled; write=0.357 s, sync=0.004 s, total=0.381 s; sync files=22, longest=0.002 s, average=0.001 s; distance=321 kB, estimate=321 kB; lsn=1/18C7340, redo lsn=1/18C7340
2026-09-07 07:06:46.118 UTC [45] LOG:  database system is shut down


FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && sudo -H -E -u discourse bash -c '
  if [[ $(git symbolic-ref --short HEAD) == release/2026.7 ]] ; then
      SKIP_DB_AND_REDIS=1 bundle exec rake assets:precompile:build assets:precompile:pretty_text
  else
      SKIP_DB_AND_REDIS=1 bundle exec rake assets:precompile:build
  fi
' failed with return #<Process::Status: pid 729 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.4.0/gems/pups-1.4.0/lib/pups/exec_command.rb:138:in 'Pups::ExecCommand#spawn'
exec failed with the params {"cd" => "$home", "tag" => "build", "hook" => "assets_precompile_build", "cmd" => ["sudo -H -E -u discourse bash -c '\n  if [[ $(git symbolic-ref --short HEAD) == $version ]] ; then\n      SKIP_DB_AND_REDIS=1 bundle exec rake assets:precompile:build assets:precompile:pretty_text\n  else\n      SKIP_DB_AND_REDIS=1 bundle exec rake assets:precompile:build\n  fi\n'"]}
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.
582d39a0c9c78bab114c5abfda91bc8ea8322552034c78ee50f92c504d58323c

我的app.yml

templates:
  - templates/postgres.template.yml
  - templates/redis.template.yml
  - templates/web.template.yml
  - templates/web.ratelimited.template.yml
  - templates/web.ssl.template.yml
  - templates/web.letsencrypt.ssl.template.yml
  - templates/web.china.template.yml
expose:
  - 80:80
  - 443:443
params:
  db_default_text_search_config: pg_catalog.english
  db_shared_buffers: 768MB
  version: release/2026.7
env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8
  // ...
  UNICORN_WORKERS: 4
  DISCOURSE_DOWNLOAD_PRE_BUILT_ASSETS: 0

看上去是更新遗漏了什么。下面是使用AI分析的结果:

问题说明

问题出在 Docker 基础镜像release/2026.7 分支代码 之间的版本不匹配:


发生了什么

引导(bootstrap)过程中,Docker 基础镜像 discourse/base:2.0.20260109-0020 内置的构建脚本会执行如下命令:

if [[ $(git symbolic-ref --short HEAD) == release/2026.7 ]] ; then
    bundle exec rake assets:precompile:build assets:precompile:pretty_text
    #                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    #                                     这个任务不存在!
fi


为什么失败

位置 状态
discourse/base 镜像 新版镜像要求运行 assets:precompile:pretty_text 任务
release/2026.7 分支 没有这个 rake 任务(lib/tasks/assets.rake 里未定义)
main / release/2026.8 这个任务(来自 commit cfed6b85b6c,Rolldown PrettyText 迁移)

简单说:镜像是新的,但代码分支是旧的,镜像里要求执行一个旧分支里还没有的任务。


修复方案

方案 操作
推荐:升级到 release/2026.8 修改容器配置文件里的 version: tests-passed 或分支名,该分支包含此任务
降级基础镜像 使用不包含 pretty_text 构建步骤的旧版 discourse/base 镜像
手动添加空任务 lib/tasks/assets.rake 中添加一个空的 assets:precompile:pretty_text 任务(临时方案)

该任务存在于 main/latest 和 2026.8.0 分支中:

有意思!

你能切换到 2026.8.x 版本吗?