Harsha M V
Harsha M V

Reputation: 54949

PG::UndefinedFile: ERROR: could not open extension control file

After upgrading Postgres i am getting the following error when i try to migrate the database.

enable_extension(:postgis)
  SQL (17.2ms)  CREATE EXTENSION IF NOT EXISTS "postgis"
PG::UndefinedFile: ERROR:  could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "postgis"
   (0.3ms)  ROLLBACK
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedFile: ERROR:  could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "postgis"/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'
ActiveRecord::StatementInvalid: PG::UndefinedFile: ERROR:  could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "postgis"
/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'
PG::UndefinedFile: ERROR:  could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Not sure where to get started. Most other questions seem to related to Linux and when i tried to create the symlink also it did not work.

Upvotes: 5

Views: 6134

Answers (3)

Cengizz
Cengizz

Reputation: 35

Detect available postgresql postgis versions

sudo apt-cache search postgis

Install

sudo apt install postgresql-12-postgis-3-scripts 

Switch postgres user

sudo -i -u postgres

Create a database and then connect it. After this run the command for postgis extension activation

CREATE EXTENSION postgis;

Later you can check and verify it by

SELECT PostGIS_version();

Upvotes: 0

Faisal Raza
Faisal Raza

Reputation: 1567

For MacOS, installing postgis worked for me using below command:

brew install postgis

For Ubuntu, below command works:

sudo apt install postgresql-10-postgis-scripts

Upvotes: 3

Artyom Kalmykov
Artyom Kalmykov

Reputation: 390

You should install postgresql-9.4-postgis-2.1

Upvotes: 4

Related Questions