NoMethodError: 未定义方法 `min_tags_from_required_group'

嘿,Discourse 团队!

我正在 Ubuntu 的 stable (v2.8.8) 版本上尝试运行 Discourse Docker,遇到了以下错误:

rake aborted!
NoMethodError: undefined method `min_tags_from_required_group' for #<Category:0x00007fc2ffae9f38>
/src/lib/seed_data/categories.rb:114:in `create_category'
/src/lib/seed_data/categories.rb:15:in `block (2 levels) in create'
/src/lib/seed_data/categories.rb:15:in `each'
/src/lib/seed_data/categories.rb:15:in `block in create'
/src/lib/seed_data/categories.rb:14:in `create'
(eval):6:in `block (2 levels) in run_file'
/src/lib/tasks/db.rake:225:in `block (2 levels) in <main>'
/src/lib/distributed_mutex.rb:33:in `block in synchronize'
/src/lib/distributed_mutex.rb:29:in `synchronize'
/src/lib/distributed_mutex.rb:29:in `synchronize'
/src/lib/distributed_mutex.rb:14:in `synchronize'
/src/lib/tasks/db.rake:210:in `block in <main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

我到目前为止所做的额外信息:

我到目前为止所做的步骤:

sudo -s
git clone -b v2.8.8 https://github.com/discourse/discourse.git
chmod -R 2777 ./discourse
cd discourse

我之前遇到了书签问题,所以不得不:

nano db/migrate/20220104053343_add_bookmark_polymorphic_columns.rb

并粘贴了这个:discourse/db/migrate/20220322024216_add_bookmark_polymorphic_columns.rb at cd817a436574cd00f0bae339ec0c4fe2fcf2bb50 · discourse/discourse · GitHub

然后当我运行:

d/boot_dev -p --init

我收到了关于 min_tags_from_required_groups 的错误。

有人能帮忙吗?

这是开发安装还是标准安装?

如果您尝试在生产环境上运行,则应在您的 app.yml 中将版本设置为 stable。您不应像指示的那样克隆 discourse。

您有任何插件吗?

@pfaffman

谢谢回复!

这是一个开发实例,所以我没有 app.yml 文件。

没有安装插件,我只是希望在 Ubuntu 上运行一个稳定版的开发实例。

啊!我现在明白了。也许我不应该在深夜发帖。

在切换到 stable 之前,是否有数据库?也许你需要

  rake db:drop db:create db:migrate

你不需要挑选一个迁移。

1 个赞

@pfaffman

希望你周末过得愉快!感谢你的回复,我今天会进行测试并回复你!

1 个赞

@pfaffman

在执行 sudo -s 然后 d/rake db:drop db:create db:migrate 后,我遇到了以下错误:

PG::InsufficientPrivilege: ERROR:  must be owner of database discourse_development
Couldn't drop database 'discourse_development'
rake aborted!
ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR:  must be owner of database discourse_development


Caused by:
PG::InsufficientPrivilege: ERROR:  must be owner of database discourse_development

Tasks: TOP => db:drop:_unsafe
(See full trace by running task with --trace)

我进入了 d/psql 并获得了列表:

discourse-> \l
                                          List of databases
           Name           |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges    
--------------------------+----------+----------+-------------+-------------+------------------------
 discourse                | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres          +
                          |          |          |             |             | postgres=CTc/postgres +
                          |          |          |             |             | discourse=CTc/postgres
 discourse_development    | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres          +
                          |          |          |             |             | postgres=CTc/postgres +
                          |          |          |             |             | discourse=CTc/postgres
 discourse_test           | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres          +
                          |          |          |             |             | postgres=CTc/postgres +
                          |          |          |             |             | discourse=CTc/postgres
 discourse_test_multisite | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres          +
                          |          |          |             |             | postgres=CTc/postgres +
                          |          |          |             |             | discourse=CTc/postgres
 postgres                 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0                | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres           +
                          |          |          |             |             | postgres=CTc/postgres
 template1                | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres           +
                          |          |          |             |             | postgres=CTc/postgres
(7 rows)

我该如何解决这个错误?

嗯。也许自己删除并重新创建那些数据库,然后用 rake 任务迁移它们。或者赋予 discourse 用户创建和销毁的权限(我认为这更简单)。

@pfaffman

我对如何授予 discourse 用户创建和销毁的权限不太熟悉。不过,在第一个选项中,你是说我应该删除所有这些数据库,然后运行 d/rake db:create db:migrate?是这样吗?

1 个赞

搜索一下 “postgres 用户角色” 之类的。我就是这么做的。大概是这样的:

su - postgres
psql
grant all rights to usee 'discoursev;

但那可能也是错的。

@pfaffman

感谢您到目前为止的帮助!在进一步排查 psql 问题之前,我想先退一步,我的主要目标是在 Ubuntu 上运行 Discourse docker 开发环境(稳定版),这在 Mac 上运行正常且符合预期。我是否应该能够做到这一点而没有这些表和迁移错误?当我尝试进行全新安装时,会出现书签错误,在解决该错误后,会出现此 NoMethodError,现在是 InsufficientPrivilege 错误。

起初我以为是因为我在 test-passed 上,然后切换到稳定版导致了问题,但即使在全新的空 Ubuntu 实例中,NoMethodError 仍然会出现,这是在没有任何先前数据库存在的情况下,我只是按照这里的步骤 #1 和步骤 #2 操作:

您能否在 Ubuntu 上安装稳定版而没有任何问题?

顶一下这个帖子!想知道是否有人成功在 Ubuntu 的稳定版本上运行了开发者环境。

尝试

   ./bundle exec rake db:drop db:create db:migrate

@pfaffman

感谢您的回复!不幸的是,我一直遇到同样的问题:

d/bundle exec rake db:drop db:create db:migrate
PG::InsufficientPrivilege: ERROR:  must be owner of database discourse_development
Couldn't drop database 'discourse_development'
rake aborted!
ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR:  must be owner of database discourse_development
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'

Caused by:
PG::InsufficientPrivilege: ERROR:  must be owner of database discourse_development
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => db:drop:_unsafe
(See full trace by running task with --trace)

我尝试在一个全新的实例上(从头开始,没有现有的数据库或信息)按照新手指南进行操作,但结果仍然一样。

这是我在 d/rails s 中仍然看到的错误:

NoMethodError (undefined method `min_tags_from_required_group' for #<Category:0x00007f3cca7ce5a8>)
(eval):36:in `_fast_attributes'
app/models/site.rb:70:in `block in all_categories_cache'
lib/cache.rb:94:in `fetch'
app/models/site.rb:52:in `all_categories_cache'
app/models/site.rb:78:in `categories'
app/serializers/site_serializer.rb:203:in `categories'
(eval):32:in `_fast_attributes'
app/models/site.rb:167:in `json_for'
app/controllers/application_controller.rb:595:in `preload_anonymous_data'
app/controllers/finish_installation_controller.rb:69:in `ensure_no_admins'
app/controllers/application_controller.rb:387:in `block in with_resolved_locale'
app/controllers/application_controller.rb:387:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/missing_avatars.rb:23:in `call'
lib/middleware/turbo_dev.rb:34:in `call'

那么您需要通过其他方式删除数据库。您可以搜索有关 PostgreSQL 的内容(我需要这样做时就是这样做的),或者等待记得的人在此处发帖。另一种选择是查看 discourse 用户是否有删除和创建数据库的权限。