# 无法通过UI或CLI合并用户

**URL:** https://meta.discourse.org/t/merge-users-not-possible-from-ui-or-cli/238430
**Category:** Support
**Tags:** merge-user
**Created:** [2022年九月8日 09:13 UTC](https://meta.discourse.org/t/merge-users-not-possible-from-ui-or-cli/238430 "2022-09-08T09:13:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![McFly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcfly/32/257919_2.png) [@McFly](https://meta.discourse.org/u/McFly)
#### Post date: [2022年九月8日 09:13 UTC](https://meta.discourse.org/t/merge-users-not-possible-from-ui-or-cli/238430/1 "2022-09-08T09:13:59Z")

</div>

你好社区，

> Discourse 版本：2.9.0.beta9（[42c64abe15](https://github.com/discourse/discourse/commits/42c64abe156829cc83b677e7a46d481aa97c380e)）

在成功合并两个 Discourse 社区后，出现了一些重复的用户（特别是那些没有使用相同地址的用户）。

但不幸的是，UI 中集成的用户合并工具无法正常工作，它会无限循环运行。  
所以我尝试了 CLI，但它也失败了。

```plaintext
cd /var/discourse
./launcher enter app

```

从用户 root discourse

```plaintext
rake users:merge['olduser','keepuser']

```

你们是否可以通过 UI 在你们的实例中合并用户？（我需要指出他们不是版主或管理员）

有什么想法吗？

提前致谢

以下是跟踪信息。

```plaintext
root@discoursetest-app:~# rake users:merge['olduser','keepuser'] --trace
** Invoke users:merge (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute users:merge
rake aborted!
ArgumentError: topic
/var/www/discourse/app/services/post_owner_changer.rb:13:in `block in initialize'
/var/www/discourse/app/services/post_owner_changer.rb:12:in `each'
/var/www/discourse/app/services/post_owner_changer.rb:12:in `initialize'
/var/www/discourse/app/services/user_merger.rb:71:in `new'
/var/www/discourse/app/services/user_merger.rb:71:in `change_post_owner'
/var/www/discourse/app/services/user_merger.rb:59:in `block in move_posts'
/var/www/discourse/app/services/user_merger.rb:57:in `each'
/var/www/discourse/app/services/user_merger.rb:57:in `move_posts'
/var/www/discourse/app/services/user_merger.rb:14:in `merge!'
/var/www/discourse/app/tasks/users.rake:50:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `execute'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli.rb:483:in `exec'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli.rb:31:in `dispatch'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli.rb:25:in `start'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/exe/bundle:48:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/exe/bundle:36:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => users:merge

```

---

<div class="post-metadata">

### Author: ![nicoangelo\_nuki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nicoangelo_nuki/32/282094_2.png) [@nicoangelo\_nuki](https://meta.discourse.org/u/nicoangelo_nuki)
#### Post date: [2022年十一月16日 09:38 UTC](https://meta.discourse.org/t/merge-users-not-possible-from-ui-or-cli/238430/2 "2022-11-16T09:38:10Z")

</div>

你好，

我今天遇到了完全相同的问题。版本稍旧（2.8.3），但在 UI 和 CLI 上结果相同。旧用户不是管理员，但新用户是。

如果有人能对此有所阐明，将不胜感激。

谢谢

* * *

CLI 输出：

```plaintext
rake --trace users:merge['old_user','new_user']
** Invoke users:merge (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute users:merge
rake aborted!
ArgumentError: ArgumentError
/var/www/discourse/app/services/post_owner_changer.rb:12:in `initialize'
/var/www/discourse/app/services/user_merger.rb:71:in `new'
/var/www/discourse/app/services/user_merger.rb:71:in `change_post_owner'
/var/www/discourse/app/services/user_merger.rb:59:in `block in move_posts'
/var/www/discourse/app/services/user_merger.rb:57:in `each'
/var/www/discourse/app/services/user_merger.rb:57:in `move_posts'
/var/www/discourse/app/services/user_merger.rb:14:in `merge!'
/var/www/discourse/lib/tasks/users.rake:50:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `execute'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/cli.rb:484:in `exec'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/cli.rb:31:in `dispatch'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/cli.rb:25:in `start'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/exe/bundle:48:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/exe/bundle:36:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => users:merge

```

---

<div class="post-metadata">

### Author: ![per1234](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/per1234/32/569645_2.png) [@per1234](https://meta.discourse.org/u/per1234)
#### Post date: [2025年五月14日 14:28 UTC](https://meta.discourse.org/t/merge-users-not-possible-from-ui-or-cli/238430/3 "2025-05-14T14:28:41Z")

</div>

我遇到了类似的问题，并找到了原因和解决方案。我想在这里添加一个注释，以防我的发现能帮助到其他遇到相同问题并在此主题中进行研究的人。

我已在此分享：

> [@我正在尝试合并用户帐户](https://meta.discourse.org/t/im-attempting-to-merge-user-accounts/342147/5):
>
> 我遇到了类似的问题，所以在此分享我的发现，希望能帮助到遇到此问题的人。 在我的情况下，账户合并操作卡在了“合并进度”对话框中，该对话框在“更改帖子所有者…”和“更新用户名…”消息之间来回循环，永远无法完成。 通过查看管理员操作日志 (/admin/logs/staff\_action\_logs)，我可以看到，尽管在我触发合并后，许多帖子的所有权立即被转移，但没有进一步的操作记录，这证明该操作确实卡住了，而不是仅仅需要很长时间来处理所有帖子。 当我检查错误日志 (/logs/) 时，我发现周期性地出现“Job exception: topic”错误，回溯信息如下： /var/www/discourse/app/services/post\_owner\_changer.rb:12:in `block in initialize' /var/www/discourse/app/services/post_owner_changer.rb:11:in `each' /var/www/discourse/app/services/post\_owner\_changer.rb:11:in `in…
