NoMethodError: undefined method `min_tags_from_required_group'

Hey Discourse team!

I’m trying to run Discourse Docker on Ubuntu on stable (v2.8.8) and I’m running into the following error:

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)

Additional Info of what I’ve done so far:

What I’ve done so far to get here:

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

I ran into some bookmark issues eariler so I had to:

nano db/migrate/20220104053343_add_bookmark_polymorphic_columns.rb

and pasted this: discourse/20220322024216_add_bookmark_polymorphic_columns.rb at cd817a436574cd00f0bae339ec0c4fe2fcf2bb50 · discourse/discourse · GitHub

Then when I run:

d/boot_dev -p --init

I get the error about min_tags_from_required_groups.

Can anyone assist?

Is this a development installation or a standard install?

If you’re trying to run on production then you’d set the version to stable in your app.yml. You wouldn’t clone discourse as you indicated.

Do you have any plugins?

Hey @pfaffman ,

Thanks for responding!

This is a development instance, so I don’t have the app.yml

No plugins installed, I was just hoping to run a development instance on stable on Ubuntu.

Ah! I see now. Perhaps I shouldn’t post on the middle of the night.

Was there a database before you switched to stable? maybe you need to

  rake db:drop db:create db:migrate

You shouldn’t need to cherry pick a migration.

1 Like

Hey @pfaffman ,

Hope you had an awesome weekend! Thanks for responding, will test this today and get back to you!

1 Like

Hey @pfaffman ,

After going sudo -s then d/rake db:drop db:create db:migrate, I got the following error:

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)

I went into d/psql and got the list:

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)

How do I go about resolving this error?

Hmm. Maybe just delete and recreate those databases yourself and just migrate it with the rake task. Or give the discourse user rights to create and destroy (I think that’s easier).

Hey @pfaffman ,

I’m not too familiar on the process of giving the discourse user rights to create and destroy unfortunately. In the first option though, are you saying I should just delete all these databases, then run d/rake db:create db:migrate ? Is that correct?

1 Like

Google “postgres user roles” or something like that. That’s what I do. It’s something like this

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

But that’s probably wrong

Hey @pfaffman ,

Thanks for your help so far! I just want to take a step back before going further into troubleshooting psql, I’m mainly aiming to just run the Discourse docker development environment (on stable) on Ubuntu, which runs fine and as expected on Mac. Shouldn’t I be able to do this without these table & migration errors? When I attempt to do a clean install I get the bookmark error, and after resolving that I get this NoMethodError, and now InsufficientPrivilege error.

Initially I thought it was because I was on test-passed then switching to stable caused the issue, but even in a clean empty Ubuntu instance, the NoMethodError still pops up, this is without any prior DBs exisiting, just did Step #1 and Step #2 here:

Are you able to install stable on Ubuntu with no issues?

Bumping this thread! Wondering if anyone else is successful in running a developer environment on stable version on Ubuntu.

Try

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

Hey @pfaffman ,

Thanks for your response! Unfortunately I keep running into the same issue:

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)

I’ve attempted this on an empty instance (restarted from the start, no existing DBs or information) using the beginner’s guide and it renders the same result.

This is the error I still get in 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'

Then you’ll need to drop the database some other way. You can Google stuff about postgres (that’s what I do when I need to do it) or wait for someone who can remember to post here. The other option is to see that the discourse user has rights to drop and create databases.