The Problem:
While attempting to restore databases from .sql files using pgAdmin4 on macOS 13.5.2 with Apple M2 chip, an error message is encountered:
pg_restore: error: could not execute query: ERROR: could not open extension control file "/opt/homebrew/opt/postgresql@13/share/postgresql@13/extension/postgis.control": No such file or directory
Additionally, trying to create the ‘postgis’ extension in the psql terminal results in the same error message.
Relevant information:
which psql
returns:/opt/homebrew/opt/postgresql@13/bin/psql
.which pg_config
returns:/opt/homebrew/opt/postgresql@13/bin/pg_config
.brew info postgis
shows:postgis: stable 3.3.4 (bottled), HEAD
.brew info postgresql@13
indicates:postgresql@13: stable 13.12 (bottled) [keg-only]
.
The goal is to resolve the error and enable successful database restoration and extension creation.
The Solutions:
Solution 1: Downgrade to PostgreSQL 14
The issue may arise due to version incompatibility between PostgreSQL and PostGIS. In this case, the installed versions are PostgreSQL 13 and PostGIS 3.3.4, which are not compatible. To resolve the problem, downgrade PostgreSQL to version 14, which is compatible with PostGIS 3.3.4.
- Stop the current PostgreSQL service:
- Start PostgreSQL 14:
- Try creating/using the PostGIS extension again. The error should be resolved.
brew services stop postgresql@15
brew services start postgresql@14
Q&A
How to solve "could not open extension control file "/opt/homebrew/opt/postgresql@13/share/postgresql@13/extension/postgis.control"?"
The error could be caused by version mismatched. Try using compatible versions of postgresql and postgis.
What to do if I am using the same compatible versions of Postgis and Postgresql?
Try running "brew reinstall postgis" to reinstall postgis latest version.
Video Explanation:
The following video, titled "How to Solve Excel Cannot Open the File ... Because the File Format ...", provides additional insights and in-depth exploration related to the topics discussed in this post.
How to Solve Excel Cannot Open the File ... Because the File Format or File Extension Is Not Valid. Did you get an error message of 'Excel ...
The following video, titled "How to Solve Excel Cannot Open the File ... Because the File Format ...", provides additional insights and in-depth exploration related to the topics discussed in this post.
How to Solve Excel Cannot Open the File ... Because the File Format or File Extension Is Not Valid. Did you get an error message of 'Excel ...