升级/重建 Discourse 时遇到错误

我在尝试升级/重建我的 Discourse 时遇到了错误:

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle install --jobs $(nproc --ignore=1) --retry 3' failed with return #<Process::Status: pid 1868 exit 18>
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" => "bundle_exec", "cmd" => ["su discourse -c 'bundle install --jobs $(nproc --ignore=1) --retry 3'", "su discourse -c 'bundle clean'", "su discourse -c 'find /var/www/discourse/vendor/bundle -name cache -not -path \"*/gems/*\" -type d -exec rm -rf {} +'", "su discourse -c 'find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +'"]}
bootstrap failed with exit code 18
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.

我看到上面有这些信息:

Fetching gem metadata from https://rubygems.org/.
Fetching bundler 4.0.23
Installing bundler 4.0.23
Your Ruby version is 3.4.10, but your Gemfile specified ~> 4.0.0
128:signal-handler (1794492346) Received SIGTERM scheduling shutdown...

我不知道,但你当时是不是内存不足了?

我的内存使用正常。我认为这是来自 docker-image/git 的内存限制导致的。

100Gb 就像是 git 错误中的内存限制吗?

是的,这是 100GB。所以肯定有什么东西出错了。

看起来你的 /var/discourse 目录比较旧——如果你运行 ./launcher rebuild,它应该会自动拉取更新。

为什么 git pull 需要 100GB,我也无法解释。

这是标准安装吗?根据查看源代码或仪表板,安装版本是多少?

你的 *.yml 文件中这部分看起来是怎样的?

  ## 此容器应使用哪个 Git 修订版?(默认值:tests-passed)
  #version: tests-passed

请发布更多日志文件内容:最后几百行应该就足够了。

这是一个 standard(独立)实例

我认为它使用了默认值:

  ## 此容器应使用哪个 Git 版本?(默认:tests-passed)
  #version: v2.9.0.beta6
  #version: tests-passed
I, [2026-11-12T14:51:02.865447 #1]  INFO -- : > cd /var/www/discourse && if [ -f yarn.lock ]; then
  if [ -d node_modules/.pnpm ]; then
    echo "此版本的 Discourse 使用 yarn,但预装了 pnpm node_modules。正在清理..."
    find ./node_modules ./app/assets/javascripts/*/node_modules -mindepth 1 -maxdepth 1 -exec rm -rf {} +
  fi
  su discourse -c 'yarn install --frozen-lockfile && yarn cache clean'
else
  su discourse -c 'CI=1 pnpm install --frozen-lockfile && pnpm prune'
fi
Scope: all 56 workspace projects
? Verifying lockfile against supply-chain policies (1676 entries)...
Progress: resolved 1620, reused 0, downloaded 96, added 96
Progress: resolved 1620, reused 0, downloaded 342, added 320
Progress: resolved 1620, reused 0, downloaded 517, added 512
Downloading @fortawesome/fontawesome-free@7.3.1: 0.00 B/6.61 MB
Progress: resolved 1620, reused 0, downloaded 630, added 608
Progress: resolved 1620, reused 0, downloaded 740, added 736
Progress: resolved 1620, reused 0, downloaded 836, added 832
Progress: resolved 1620, reused 0, downloaded 977, added 960
Downloading lefthook-linux-x64@2.2.1: 0.00 B/5.50 MB
Downloading ace-builds@1.44.0: 0.00 B/10.10 MB
Downloading @typescript/typescript-linux-x64@7.1.0-dev.20260930.4: 0.00 B/10.15 MB
Downloading @rolldown/binding-linux-x64-gnu@1.2.7: 0.00 B/7.96 MB
Progress: resolved 1620, reused 0, downloaded 1383, added 1376
Progress: resolved 1620, reused 0, downloaded 1495, added 1472
Progress: resolved 1620, reused 0, downloaded 1592, added 1568
[WARN] Tarball download average speed 32 KiB/s (size 99 KiB) is below 50 KiB/s: https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz (GET)
[WARN] Tarball download average speed 37 KiB/s (size 52 KiB) is below 50 KiB/s: https://registry.npmjs.org/@discourse/itsatrap/-/itsatrap-2.0.10.tgz (GET)
[WARN] Request took 11300ms: https://registry.npmjs.org/@typescript-eslint%2Ftypescript-estree
Downloading @typescript/typescript-linux-x64@7.1.0-dev.20260930.4: 5.08 MB/10.15 MB
✓ Lockfile passes supply-chain policies (1676 entries in 16.2s)
Lockfile is up to date, resolution step is skipped
Packages: +1620 -677
++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------
Progress: resolved 1620, reused 0, downloaded 1612, added 1620, done
.../lefthook@2.2.1/node_modules/lefthook postinstall$ node postinstall.js
.../lefthook@2.2.1/node_modules/lefthook postinstall: Done
. postinstall$ node script/copy_vendored_assets.mjs
. postinstall: Done
. prepare$ pnpm types:generate
. prepare: $ pnpm --dir=frontend/discourse-i18n tsc && pnpm --dir=frontend/discourse-types generate-external
. prepare: $ pnpm compile-dts-generator && pnpm generate-external-types
. prepare: $ tsc --ignoreConfig --types node dts-generator.ts --target esnext --moduleResolution nodenext --module nodenext
. prepare: $ node generate-external-types.js
. prepare: Done
. prepare: Done

devDependencies:
- @discourse/lint-configs 3.2.0
+ @discourse/lint-configs 3.9.1
+ @discourse/moment-timezone-names-translations 1.0.0
- @fortawesome/fontawesome-free 7.2.0
+ @fortawesome/fontawesome-free 7.3.1
- @glint/ember-tsc 1.8.11
+ @glint/ember-tsc 1.11.6
- @glint/tsserver-plugin 2.5.17
+ @glint/tsserver-plugin 2.7.9
+ @rdil/parallel-prettier 3.0.0
- concurrently 9.2.1
+ concurrently 10.0.6
+ ember-content-mapper 0.3.1
- execa 9.6.1
+ execa 10.1.0
+ jsdoc 4.0.5
- lefthook 2.1.9
+ lefthook 2.2.1
- licensee 11.1.1
+ licensee 12.0.2
+ lint-to-the-future 3.2.0
- playwright 1.59.1
- postcss-selector-parser 7.1.4
+ postcss-selector-parser 7.1.6
+ postcss-value-parser 4.2.0
+ prettier 3.8.1
- typescript 5.9.3
+ typescript 7.1.0-dev.20260930.4

Done in 29.4s using pnpm v12.11.2
Scope: all 56 workspace projects
✓ Lockfile passes supply-chain policies (verified 9s ago)
Lockfile is up to date, resolution step is skipped
Already up to date
. postinstall$ node script/copy_vendored_assets.mjs
. postinstall: Done
. prepare$ pnpm types:generate
. prepare: $ pnpm --dir=frontend/discourse-i18n tsc && pnpm --dir=frontend/discourse-types generate-external
. prepare: $ pnpm compile-dts-generator && pnpm generate-external-types
. prepare: $ tsc --ignoreConfig --types node dts-generator.ts --target esnext --moduleResolution nodenext --module nodenext
. prepare: $ node generate-external-types.js
. prepare: Done
. prepare: Done
Done in 7.1s using pnpm v12.11.2
I, [2026-11-12T14:51:47.587926 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle install --jobs $(nproc --ignore=1) --retry 3'
Bundler 4.0.11 is running, but your lockfile was generated with 4.0.23. Installing Bundler 4.0.23 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 4.0.23
Installing bundler 4.0.23
Your Ruby version is 3.4.10, but your Gemfile specified ~> 4.0.0
I, [2026-11-12T14:51:53.410346 #1]  INFO -- : Terminating async processes
I, [2026-11-12T14:51:53.410425 #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-11-12T14:51:53.410482 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 128
128:signal-handler (1794495113) Received SIGTERM scheduling shutdown...
2026-11-12 14:51:53.410 UTC [45] LOG:  received fast shutdown request
2026-11-12 14:51:53.448 UTC [45] LOG:  aborting any active transactions
2026-11-12 14:51:53.452 UTC [45] LOG:  background worker "logical replication launcher" (PID 62) exited with exit code 1
2026-11-12 14:51:53.452 UTC [57] LOG:  shutting down
2026-11-12 14:51:53.457 UTC [57] LOG:  checkpoint starting: shutdown immediate
128:M 12 Nov 2026 14:51:53.459 * User requested shutdown...
128:M 12 Nov 2026 14:51:53.459 * Saving the final RDB snapshot before exiting.
2026-11-12 14:51:53.519 UTC [57] LOG:  checkpoint complete: wrote 1 buffers (0.0%), wrote 3 SLRU buffers; 0 WAL file(s) added, 0 removed, 0 recycled; write=0.020 s, sync=0.005 s, total=0.067 s; sync files=3, longest=0.002 s, average=0.002 s; distance=3 kB, estimate=3 kB; lsn=1/CAA1B830, redo lsn=1/CAA1B830
128:M 12 Nov 2026 14:51:53.536 * DB saved on disk
128:M 12 Nov 2026 14:51:53.536 # Redis is now ready to exit, bye bye...
2026-11-12 14:51:53.554 UTC [45] LOG:  database system is shut down


FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle install --jobs $(nproc --ignore=1) --retry 3' failed with return #<Process::Status: pid 1947 exit 18>
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" => "bundle_exec", "cmd" => ["su discourse -c 'bundle install --jobs $(nproc --ignore=1) --retry 3'", "su discourse -c 'bundle clean'", "su discourse -c 'find /var/www/discourse/vendor/bundle -name cache -not -path \"*/gems/*\" -type d -exec rm -rf {} +'", "su discourse -c 'find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +'"]}
bootstrap failed with exit code 18
** FAILED TO BOOTSTRAP ** 请向上滚动并查找较早的错误消息,可能存在多个错误。

我能简单地修复 Ruby version 吗?

git --version
git version 2.53.0
git remote -v
origin	https://github.com/discourse/discourse_docker.git (fetch)
origin	https://github.com/discourse/discourse_docker.git (push)

我使用的是 Ubuntu 26.04,目前正在处理 7.0.0-43.43 版本中的某些问题,以修复当前的 CVE-2026-98432 – Linux Kernel 和 CVE-2026-109518 – APT。

谢谢。这是你正在使用的配方吗:

cd /var/discourse
git pull
./launcher rebuild app

?

是的,

  1. git pull → 内存出现错误
  2. ./launcher rebuild app → Ruby 版本出现错误

谢谢。据我理解,任何 Ruby 版本不匹配的问题都与你的操作系统无关,而是与 Docker 镜像有关。当然,Docker 镜像内部应当保持一致性。

导致 git pull 失败的内存问题需要优先解决,但我目前没有任何想法。不过,可以尝试执行以下命令,看看是否有效:

git fetch --depth=1

我认为始终值得检查机器配置:

df -h /
free

另外,也许

`git fetch --depth=1`
仍然出现错误。

请分享你的完整 app.yml。看起来你可能使用了固定镜像…

我已经修复了 Git 的问题,现在一切正常。

你能跟全班分享一下问题是什么吗?