joecooldoo is encountering a PG::UndefinedTable: ERROR: relation "pg_range" does not exist while setting up Discourse for development on WSL2 (Ubuntu 18.04.5) using PostgreSQL 9.2, which merefield notes is outdated and recommends upgrading to 13.x. Despite upgrading PostgreSQL, the same error persists joecooldoo. Falco suggests the issue may stem from an old or corrupt database, referencing a Stack Overflow solution. joecooldoo asks how to create a new database, then later reports a new error: PG::ConnectionBad: connection to server on socket... failed, indicating PostgreSQL isn’t running joecooldoo. Switching to the Docker-based setup guide, joecooldoo hits a permission error during migration: mkdir: cannot create directory ‘/src/public/plugins/’: Permission denied. The issue remains unresolved as of joecooldoo. Key problems include outdated PostgreSQL, potential database corruption, service misconfiguration, and Docker filesystem permissions.
When I run bundle exec rake db:create it just errors out and says:
[Warning] Discourse recommends developing using Ruby v3.1.3 or above. You are using v2.7.6.
PG::UndefinedTable: ERROR: relation "pg_range" does not exist
LINE 3: LEFT JOIN pg_range as r ON oid = rngtypid
^
Couldn't create 'discourse_development' database. Please check your configuration.
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "pg_range" does not exist
LINE 3: LEFT JOIN pg_range as r ON oid = rngtypid
^
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `load'
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `<main>'
Caused by:
PG::UndefinedTable: ERROR: relation "pg_range" does not exist
LINE 3: LEFT JOIN pg_range as r ON oid = rngtypid
^
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `load'
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)
What do I do?
I am using WSL 2 and Ubuntu 18.04.5, and PostgreSQL version 9.2
[Warning] Discourse recommends developing using Ruby v3.1.3 or above. You are using v2.7.6.
PG::UndefinedTable: ERROR: relation "pg_range" does not exist
LINE 3: LEFT JOIN pg_range as r ON oid = rngtypid
^
Couldn't create 'discourse_development' database. Please check your configuration.
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "pg_range" does not exist
LINE 3: LEFT JOIN pg_range as r ON oid = rngtypid
^
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `load'
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `<main>'
Caused by:
PG::UndefinedTable: ERROR: relation "pg_range" does not exist
LINE 3: LEFT JOIN pg_range as r ON oid = rngtypid
^
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `load'
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)
[Warning] Discourse recommends developing using Ruby v3.1.3 or above. You are using v2.7.6.
We could not find your database: postgres. Which can be found in the database configuration file located at config/database.yml.
To resolve this issue:
- Did you create the database for this app, or delete it? You may need to create your database.
- Has the database name changed? Check your database.yml config has the correct database name.
To create your database, run:
bin/rails db:create
Couldn't create 'discourse_development' database. Please check your configuration.
rake aborted!
ActiveRecord::NoDatabaseError: We could not find your database: postgres. Which can be found in the database configuration file located at config/database.yml.
To resolve this issue:
- Did you create the database for this app, or delete it? You may need to create your database.
- Has the database name changed? Check your database.yml config has the correct database name.
To create your database, run:
bin/rails db:create
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `load'
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `<main>'
Caused by:
PG::ConnectionBad: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `load'
/home/joecooldoo/.rbenv/versions/2.7.6/bin/bundle:25:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)