# 新安装失败（全新安装）

**URL:** https://meta.discourse.org/t/new-installation-fails-fresh-install/147461
**Category:** Bug
**Created:** [2020年四月9日 19:35 UTC](https://meta.discourse.org/t/new-installation-fails-fresh-install/147461 "2020-04-09T19:35:53Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![oiler](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/oiler/32/120225_2.png) [@oiler](https://meta.discourse.org/u/oiler)
#### Post date: [2020年四月9日 19:35 UTC](https://meta.discourse.org/t/new-installation-fails-fresh-install/147461/1 "2020-04-09T19:35:54Z")

</div>

可能与 [147425](https://meta.discourse.org/t/new-installation-fails-on-migration/147425) 相关，但我新建了一个线程，因为我的情况是全新安装，而非迁移。

我在两个不同的干净 Ubuntu 18.04 实例（一个 Linode，一个 Digital Ocean）上尝试通过 Docker 脚本进行自助安装。两次都出现了相同的错误。

错误截图  
[![](https://global.discourse-cdn.com/meta/original/3X/6/f/6f49257f3f95ff3fb166d770160431c157a83f8a.jpeg) ](https://dl.dropboxusercontent.com/s/e4cmf38j4g083c4/Screenshot%202020-04-09%2014.32.38.png?dl=0)

错误输出

```plaintext
== 20180917024729 RemoveSuperfluousColumns: 正在迁移 =========================

警告
-------------------------------------------------------------------------------------
在迁移过程中尝试删除或重命名列。
使用的 SQL 为：'ALTER TABLE user_profiles DROP COLUMN IF EXISTS card_image_badge_id'

请使用 `rails g post_migration` 生成一个部署后迁移脚本来删除或重命名列。

注意，为尽量减少干扰，请在您的 ActiveRecord 模型上使用 self.ignored_columns = ["列名"]，大约 6 个月后可移除该设置。

此保护机制旨在防止删除当前正在被运行中的应用使用的列。

I, [2020-04-09T15:07:30.875957 #1] INFO -- : 正在终止异步进程
I, [2020-04-09T15:07:30.876041 #1] INFO -- : 向 HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/10/bin/postmaster -D /etc/postgresql/10/main pid: 64 发送 INT 信号
2020-04-09 15:07:30.876 UTC [64] LOG: 收到快速关闭请求
I, [2020-04-09T15:07:30.876354 #1] INFO -- : 向 exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 181 发送 TERM 信号
181:signal-handler (1586444850) 收到 SIGTERM 信号，计划关闭...
181:M 09 Apr 2020 15:07:30.954 # 用户请求关闭...
181:M 09 Apr 2020 15:07:30.954 * 退出前保存最终的 RDB 快照。
181:M 09 Apr 2020 15:07:30.959 * 数据库已保存到磁盘
181:M 09 Apr 2020 15:07:30.960 # Redis 现已准备退出，再见...
2020-04-09 15:07:30.880 UTC [64] LOG: 中止所有活动事务
2020-04-09 15:07:30.886 UTC [64] LOG: 工作进程：逻辑复制启动器（PID 73）以退出代码 1 退出
2020-04-09 15:07:30.894 UTC [68] LOG: 正在关闭
2020-04-09 15:07:31.151 UTC [64] LOG: 数据库系统已关闭

失败
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' 执行失败，返回状态码 #<Process::Status: pid 12943 exit 1>
失败位置：/pups/lib/pups/exec_command.rb:112:in `spawn'
执行失败，参数为 {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
90378b39f271ddf9c4ba2628e28ceffd9ede8f3c6cdb4815b12f8b3ae5a218ac
**引导失败** 请向上滚动查看更早的错误信息，可能不止一条。
./discourse-doctor 可能有助于诊断问题。

```

---

<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: [2020年四月9日 19:40 UTC](https://meta.discourse.org/t/new-installation-fails-fresh-install/147461/2 "2020-04-09T19:40:00Z")

</div>

我们已回滚了相关提交，请再试一次。

---

<div class="post-metadata">

### Author: ![oiler](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/oiler/32/120225_2.png) [@oiler](https://meta.discourse.org/u/oiler)
#### Post date: [2020年四月9日 19:50 UTC](https://meta.discourse.org/t/new-installation-fails-fresh-install/147461/3 "2020-04-09T19:50:07Z")

</div>

好的，我需要切换 DNS，大约需要一小时。稍后向您汇报。谢谢。

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2020年四月9日 20:11 UTC](https://meta.discourse.org/t/new-installation-fails-fresh-install/147461/4 "2020-04-09T20:11:50Z")

</div>

好的，@sam 会在他的澳大利亚周一查看此事。

---

<div class="post-metadata">

### Author: ![oiler](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/oiler/32/120225_2.png) [@oiler](https://meta.discourse.org/u/oiler)
#### Post date: [2020年四月9日 21:16 UTC](https://meta.discourse.org/t/new-installation-fails-fresh-install/147461/5 "2020-04-09T21:16:54Z")

</div>

安装已经正常工作了。谢谢你的帮助！

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2020年四月9日 21:23 UTC](https://meta.discourse.org/t/new-installation-fails-fresh-install/147461/6 "2020-04-09T21:23:17Z")

</div>

我会在周一查看，但这没有意义，因为我有一个特定的提交避免了加载该代码。

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2020年四月14日 01:39 UTC](https://meta.discourse.org/t/new-installation-fails-fresh-install/147461/7 "2020-04-14T01:39:20Z")

</div>

已根据以下内容修复：

> <https://github.com/discourse/discourse/commit/e2284cf7391aa94ed2f22662305bc14e9e51262c>
>
> This reverts commit 8b46f14744d4bab9339d075825914d86da6bd5eb.
> 
> It corrects the r…eason for the revert:
> 
> We rely on SafeMigrate existing cause we call it from migrations,
> Zeitwerk will autoload it.
> 
> Instead of previous pattern we explicitly bypass all the hacks in
> production mode.
> 
> We need to disable SafeMigrate cause it is not thread safe.
> 
> A thread safe implementation is possible but not worth the effort,
> we catch the issues in dev and test.

Zeitwerk 自动加载了此项，因为我们有某些迁移会对 SafeMigrate 执行覆盖。

我已在该类中禁用了此功能。

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2020年四月14日 01:39 UTC](https://meta.discourse.org/t/new-installation-fails-fresh-install/147461/8 "2020-04-14T01:39:24Z")

</div>


