Error could not open extension control file no such file or directory

ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/postgis.control": No such file or directory Is what I get when I try to CREATE EXTENSION postgis; can anybody tel...

ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/postgis.control": No such file or directory

Is what I get when I try to CREATE EXTENSION postgis; can anybody tell me why is it so and what can I do to fix it?

asked Sep 9, 2013 at 10:20

Xeen's user avatar

3

The following will get you a working postgis install on Ubuntu 12.04 (Note: also tested on 13.10)

echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/postgis.list
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-9.3-postgis-2.1 postgresql-client-9.3
sudo -u postgres psql -c 'create extension postgis;'

Based on the docs at https://wiki.postgresql.org/wiki/Apt

answered Nov 20, 2013 at 11:43

dwurf's user avatar

dwurfdwurf

12.3k6 gold badges29 silver badges42 bronze badges

5

You need to install postgresql-9.1-postgis-scripts. In Ubuntu or Debian, you need to run the following command as root:

apt-get install postgresql-9.1-postgis-scripts

This adds the files needed to create the postgis extensions.

Arman H's user avatar

Arman H

5,36810 gold badges50 silver badges75 bronze badges

answered Apr 30, 2014 at 21:01

Roldan Vargas's user avatar

4

Installing this package did the trick for me on my Linux Mint 16 box:

# install hstore postgresql extension.
sudo apt-get install postgresql-contrib

answered Oct 16, 2014 at 18:01

Alireza's user avatar

AlirezaAlireza

2,59117 silver badges18 bronze badges

4

Daniel Vérité is close to the truth, but not enough. The package missing is postgresql-9.1-postgis-2.0:

sudo apt-get install postgresql-9.1-postgis-2.0

answered Nov 27, 2013 at 9:42

Luís de Sousa's user avatar

Luís de SousaLuís de Sousa

5,29810 gold badges46 silver badges82 bronze badges

2

Presumably the postgis version you installed is 1.5.x which doesn’t come as an extension, but as a couple of SQL scripts that need to be manually applied to create the necessary SQL objects.

Also the postgis package is not enough, it contains only stuff that doesn’t depend on PG version, you need postgresql-9.1-postgis (dpkg -L package-name is handy to check out the files provided by any particular package).

Once the installation paths are known, the official install documentation should be good enough to set up the template database.

answered Sep 12, 2013 at 14:10

Daniel Vérité's user avatar

Daniel VéritéDaniel Vérité

56.1k15 gold badges125 silver badges150 bronze badges

Just resolved it.
You have to uninstall postgis-1.5. You installed it instaed of PostGIS 2.0. As soon as you will install postgis-2.0 you will see corrected libraries in extension directory.
Before installing you should to add a correct repository (see http://docs.pgrouting.org/2.0/en/doc/src/installation/index.html#ubuntu-debian). Use ppa:ubuntugis/ubuntugis-unstable for PostGIS 2.0.
Try one of

apt-get remove postgis
apt-get remove postgresql-9.1-postgis
apt-get install postgresql-9.1-postgis

I couldn’t remove and install because of dependencies error.
After a few attmpts, I just removed postgresql-9.1-postgis and apt-get offer me upgrade it to 2.0.

Shaun McDonald's user avatar

answered Jan 10, 2014 at 12:57

Dmitry Lutskov's user avatar

1

I had the same problem on my Window 8.1 setup.

I solved it by simply using Application StackBuilder which comes with Postgres and installing PostGIS again (despite not having uninstalled it)

Works fine now!

answered Sep 10, 2014 at 14:41

CodyBugstein's user avatar

CodyBugsteinCodyBugstein

21k59 gold badges200 silver badges352 bronze badges

0

In C:Program FilesPostgreSQL9.4 I found uninstall-postgis-bundle-pg94x64-2.1.5-2.exe. Running that fixed my problem, which was caused by a reinstall of PostgreSQL without first uninstalling, and without installing PostGIS the second time around. That’s what happens when you more than one person installing stuff..

answered Mar 26, 2015 at 9:18

julian's user avatar

Make sure that you have installed this

sudo apt-get install postgresql-9.3-postgis

I was facing same issue due to missing this package.

answered Sep 24, 2014 at 12:34

vitthal-gaikwad's user avatar

Try this

apt-get install postgis

answered Sep 4, 2018 at 6:01

Susaj S N's user avatar

Susaj S NSusaj S N

9001 gold badge9 silver badges22 bronze badges

0

CentOS needs a different package for this problem. For CentOS 6, if you’re using the PGDG yum repository at http://yum.pgdgrpms.org/9.3/redhat/, install the postgresql93-contrib package with the command ‘yum install postgresql93-contrib.

Update and edit as necessary for PostgreSQL 9.4.

answered Dec 1, 2014 at 20:06

Nico Kadel-Garcia's user avatar

I had my worst nightmare while installing Postgis 2.X on SLES 12 SP1. which doesnt have compatible package in zypper repo

Here is how is resolved it on my Postgres server instance running 9.4.X

Prerequsite packages which i have installed prior to PostGis based on the errors

Proj 4 Download source cold, Build --> make install
install Gdal andjibson by adding zypper repo zypper addrepo http://download.opensuse.org/repositories/Application:Geo/SLE_12_SP1_Backports/Application:Geo.repo
zypper install gdal gdal-devel libjson-c-devel libjson

Installing Postgis

Download postgis source code (http://download.osgeo.org/postgis/source/postgis-2.3.0rc1.tar.gz)

Go to Postgis folder 
./configure --with-pgconfig=/usr/lib/postgresql94/bin/pg_config --with-geosconfig=/usr/local/bin/geos-config 
make 
make install

now if you goto postgress DB and create extension postgis; it will work

Important while configuring you should specify pg-config path and geosconfig path and You SHOULD NOT include «without Raster» as RASTER plays main role in creating the postgis extension

answered Sep 21, 2016 at 5:36

Pradeep B's user avatar

this work for me

   SELECT PostGIS_full_version();

To create postgisis run above query in query panel

And for remove postgis from your database run bellow query

   drop extension postgis

answered May 10, 2017 at 10:09

Sameer Kazi's user avatar

Sameer KaziSameer Kazi

16.9k2 gold badges34 silver badges46 bronze badges

if you are using windows system download the postgis.bundle.exe and manually install in C:/(PostgreSQLdirectory/version/ ) and that’s all .

a_horse_with_no_name's user avatar

answered Nov 1, 2017 at 16:00

Harshal's user avatar

2

I just had the same problem on Ubuntu Server 14.04.
I installed the postgis extension from the official Ubuntu repositories using apt-get install postgis.

Then, find /usr -name postgis.control didn’t return any results.

The reason was extension/postgis.control wasn’t installed because postgis-scripts wasn’t.

$ aptitude search postgis
i   libpostgis-java                                  - Geographic objects support for PostgreSQL -- JDBC support 
i   postgis                                          - Geographic objects support for PostgreSQL                 
p   postgis:i386                                     - Geographic objects support for PostgreSQL                 
i   postgis-doc                                      - Geographic objects support for PostgreSQL -- documentation
i   postgresql-9.3-postgis-2.1                       - Geographic objects support for PostgreSQL 9.3             
p   postgresql-9.3-postgis-2.1:i386                  - Geographic objects support for PostgreSQL 9.3             
i   postgresql-9.3-postgis-2.1-scripts               - PostGIS for PostgreSQL 9.3 -- scripts -- dummy package    
i   postgresql-9.3-postgis-scripts                   - Geographic objects support for PostgreSQL 9.3 -- scripts 

The solution is to install it.

On debian-like distros:

apt-get install postgis*

The aptitude package manager will automatically determine the correct package versions to install. The postgis-doc will be installed too.

EDIT

Like some people noticed in comments, the postgis* is not required because it installs some packages not strictly required to just get it to work.

The required packages are postgis and postgresql-9.x-postgis-scripts meta packages. They select the correct real version for your system.
So the commands to install the required packages are

 $ sudo apt-get install postgis postgresql-9.3-postgis-scripts

for postgresql-9.3. Ubuntu 16.04 runs postgresql-9.5 so the command becomes:

 $ sudo apt-get install postgis postgresql-9.5-postgis-scripts

You can check the success of the operation by running the following command:

find /usr -name postgis.control

On my server, it now returns:

/usr/share/postgresql/9.3/extension/postgis.control

You can now enable the extension on any database on your postgres server:

  • connect to your db with superuser (postgres by default)
  • run CREATE EXTENSION postgis;

Your public schema now contains all postgis objects and functions.

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Comments

@ubergesundheit

Hi,

I tried to run CREATE EXTENSION postgis; on the image mdillon/postgis:9.4 from the docker hub. It complained that it couldn’t find the file /usr/share/postgresql/9.4/extension/postgis.control

running bash inside the container reveals that in fact this file exists!

I already tried the following things:

  • building from this repository
  • changing ownership of /usr/share/postgresql/9.4/extension/ to the postgres user (RUN chown -R postgres:postgres /usr/share/postgresql/9.4/extension/)

Could you please look into this?

Cheers

@md5

How did you run the CREATE EXTENSION statement? Did you connect to the container with psql or did you do something else?

@ubergesundheit



Copy link


Contributor

Author

I am using fig (http://fig.sh) for running a ruby on rails app which uses postgis. When I am running fig run app rake db:migrate rails tries to create the posgis extension with CREATE EXTENSION postgis; which then fails.

@md5

I just tested this successfully:

$ docker pull mdillon/postgis:9.4
# Time passes...
$ docker run -d --name some-postgis -e POSTGRES_PASSWORD=p mdillon/postgis:9.4
4825867790a1583c8bd9c58498ed876197795166855c513fca501d7c78a53f83
$ docker run -it --link some-postgis:postgres --rm postgres 
   sh -c 'exec env PGPASSWORD="$POSTGRES_ENV_POSTGRES_PASSWORD" 
             psql -h "$POSTGRES_PORT_5432_TCP_ADDR" 
                     -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'
psql (9.4.0, server 9.4.1)
Type "help" for help.
postgres=# create database postgis;
CREATE DATABASE
postgres=# c postgis
psql (9.4.0, server 9.4.1)
You are now connected to database "postgis" as user "postgres".
postgis=# create extension postgis;
CREATE EXTENSION

@md5

Can you post your fig.yml? It might also be relevant to find out what version of Fig you’re using, but probably not.

@ubergesundheit



Copy link


Contributor

Author

fig --version returns fig 1.0.0

my fig.yml is

db:
  image: mdillon/postgis:9.4
  ports:
    - "5432"
  environment:
    - POSTGRES_PASSWORD=yoloswag

app:
  build: .
  links:
    - db
  environment:
    - RAILS_ENV=production
    - DEVISE_SECRET_KEY=swaghettiYolonaise
    - SECRET_KEY_BASE=swaghettiYolonaise
    - OAUTH_FACEBOOK_KEY=swaghettiYolonaise
    - OAUTH_FACEBOOK_SECRET=swaghettiYolonaise
    - OAUTH_TWITTER_KEY=swaghettiYolonaise
    - OAUTH_TWITTER_SECRET=swaghettiYolonaise
    - OAUTH_GOOGLE_KEY=swaghettiYolonaise
    - OAUTH_GOOGLE_SECRET=swaghettiYolonaise
    - HOSTNAME=localhost:3000
    - SMTP_HOST=smtp.mandrillapp.com
    - SMTP_PORT=25
    - SMTP_USER=SOMEUSER
    - SMTP_PASSWORD=SOMEPASS
    - EMAIL_FROM=some-email@provider.com
    - SENTRY_DSN=http://localhost

the dockerfile for the app installs postgresql-client

@md5

I can’t see anything there that would affect whether or not the extension control file would be found or readable by the Postgres process.

Any chance you could post the exact error you get back when you run fig run app rake db:migrate? You may also want to look at what fig logs db has to say after the failure.

@ubergesundheit



Copy link


Contributor

Author

the error rails produces:

== 20140418190245 CreateFeatures: migrating ===================================
-- enable_extension("postgis")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedFile: ERROR:  could not open extension control file "/usr/share/postgresql/9.4/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "postgis"/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `async_exec'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `block in exec_no_cache'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/usr/local/bundle/gems/activesupport-4.1.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `exec_no_cache'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in `enable_extension'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:656:in `block in method_missing'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:628:in `block in say_with_time'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:628:in `say_with_time'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:648:in `method_missing'
/usr/src/app/db/migrate/20140418190245_create_features.rb:3:in `change'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:602:in `exec_migration'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:586:in `block (2 levels) in migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:585:in `block in migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:584:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:759:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:1044:in `block in ddl_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/transactions.rb:208:in `transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:1044:in `ddl_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:959:in `block in migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:955:in `each'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:955:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:814:in `up'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:792:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
ActiveRecord::StatementInvalid: PG::UndefinedFile: ERROR:  could not open extension control file "/usr/share/postgresql/9.4/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "postgis"
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `async_exec'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `block in exec_no_cache'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/usr/local/bundle/gems/activesupport-4.1.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `exec_no_cache'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in `enable_extension'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:656:in `block in method_missing'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:628:in `block in say_with_time'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:628:in `say_with_time'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:648:in `method_missing'
/usr/src/app/db/migrate/20140418190245_create_features.rb:3:in `change'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:602:in `exec_migration'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:586:in `block (2 levels) in migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:585:in `block in migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:584:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:759:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:1044:in `block in ddl_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/transactions.rb:208:in `transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:1044:in `ddl_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:959:in `block in migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:955:in `each'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:955:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:814:in `up'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:792:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
PG::UndefinedFile: ERROR:  could not open extension control file "/usr/share/postgresql/9.4/extension/postgis.control": No such file or directory
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `async_exec'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `block in exec_no_cache'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/usr/local/bundle/gems/activesupport-4.1.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `exec_no_cache'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in `enable_extension'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:656:in `block in method_missing'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:628:in `block in say_with_time'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:628:in `say_with_time'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:648:in `method_missing'
/usr/src/app/db/migrate/20140418190245_create_features.rb:3:in `change'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:602:in `exec_migration'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:586:in `block (2 levels) in migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:585:in `block in migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:584:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:759:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:1044:in `block in ddl_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/transactions.rb:208:in `transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:1044:in `ddl_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:959:in `block in migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:955:in `each'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:955:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:814:in `up'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/migration.rb:792:in `migrate'
/usr/local/bundle/gems/activerecord-4.1.9/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

and fig logs db

...
db_1 | LOG:  received smart shutdown request
db_1 | LOG:  autovacuum launcher shutting down
db_1 | LOG:  shutting down
db_1 | LOG:  database system is shut down
db_1 | LOG:  database system was shut down at 2015-02-14 00:01:24 UTC
db_1 | LOG:  autovacuum launcher started
db_1 | LOG:  database system is ready to accept connections
db_1 | ERROR:  could not open extension control file "/usr/share/postgresql/9.4/extension/postgis.control": No such file or directory
db_1 | STATEMENT:  CREATE EXTENSION IF NOT EXISTS "postgis"

@md5

And you said you were able to confirm that /usr/share/postgresql/9.4/extension/postgis.control exists with that exact path? Could you provide the output of docker exec $CONTAINERID ls -l /usr/share/postgresql/9.4/extension/postgis.control?

@md5

BTW, you probably don’t want that ports: "5432". That’s exposing your container Postgres on the Docker host’s IP with a random port. The linked container will work directly with port 5432 inside the container with the ports declaration.

@ubergesundheit



Copy link


Contributor

Author

It seems fig doesn’t recognize changes in the fig yml. Earlier I had image: postgres and now it starts the postgres image :| After I changed the name of the db to postgis fig recognized the different image. It now works

Sorry I’ve bothered you :( This is a flaw in fig.

@md5

Glad you figured it out. Since we took the time to debug it, it may be worth seeing if the issue has been reported at https://github.com/docker/fig

@md5
md5

mentioned this issue

Feb 16, 2015

2 participants

@md5

@ubergesundheit

While PL/Python is an untrusted language inside PostgreSQL, I was installing it to test some of its features. First, we check to see if PL/Python is installed by attempting to create a PL/Python function:

CREATE FUNCTION pima(a integer, b integer)
RETURNS integer AS
$$
if a > b:
  return a
return b
$$ LANGUAGE plpython3u;

It likely should raise an error like this because PL/Python is an untrusted language. It’s untrusted because it runs with root privileges rather than a restricted user’s privilege. More or less, with PL/Python you can access the entire database. This makes PL/Python more of a threat than tool beyond experimentation in a test database.

ERROR:  language "plpython3u" does not exist
HINT:  Use CREATE EXTENSION to load the language into the database.

A quick query as the postgres user tells you whether or not PL/Python is installed:

SELECT * FROM pg_language;

It returns the following:

 lanname  | lanowner | lanispl | lanpltrusted | lanplcallfoid | laninline | lanvalidator | lanacl 
----------+----------+---------+--------------+---------------+-----------+--------------+--------
 internal |       10 | f       | f            |             0 |         0 |         2246 | 
 c        |       10 | f       | f            |             0 |         0 |         2247 | 
 sql      |       10 | f       | t            |             0 |         0 |         2248 | 
 plpgsql  |       10 | t       | t            |         14088 |     14089 |        14090 | 
(4 rows)

I attempted to add PL/Python with the following command:

CREATE EXTENSION plpython3u;

It raised the following error:

ERROR:  could not open extension control file "/usr/pgsql-11/share/extension/plpython3u.control": No such file or directory

The error basically appeared to occur because there’s a missing Python 3 package from what I could find on the web. I installed the missing postgresql-plpython3 package as the root superuser, which you also could install as a member of the sudoer list. The following shows how to install it as a sudoer member:

sudo yum install -y postgresql-plpython3

You should see something close to the following console output:

Last metadata expiration check: 0:43:53 ago on Fri 06 Nov 2020 10:42:28 AM MST.
Dependencies resolved.
============================================================================================================
 Package                           Architecture        Version                   Repository            Size
============================================================================================================
Installing:
 postgresql-plpython3              x86_64              11.7-2.fc30               updates               86 k
Installing dependencies:
 postgresql-server                 x86_64              11.7-2.fc30               updates              5.3 M
 
Transaction Summary
============================================================================================================
Install  2 Packages
 
Total download size: 5.3 M
Installed size: 23 M
Downloading Packages:
(1/2): postgresql-plpython3-11.7-2.fc30.x86_64.rpm                          218 kB/s |  86 kB     00:00    
(2/2): postgresql-server-11.7-2.fc30.x86_64.rpm                             3.0 MB/s | 5.3 MB     00:01    
------------------------------------------------------------------------------------------------------------
Total                                                                       2.1 MB/s | 5.3 MB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                    1/1 
  Running scriptlet: postgresql-server-11.7-2.fc30.x86_64                                               1/2 
  Installing       : postgresql-server-11.7-2.fc30.x86_64                                               1/2 
warning: /var/lib/pgsql/.bash_profile created as /var/lib/pgsql/.bash_profile.rpmnew
 
  Running scriptlet: postgresql-server-11.7-2.fc30.x86_64                                               1/2 
  Installing       : postgresql-plpython3-11.7-2.fc30.x86_64                                            2/2 
  Running scriptlet: postgresql-plpython3-11.7-2.fc30.x86_64                                            2/2 
  Verifying        : postgresql-plpython3-11.7-2.fc30.x86_64                                            1/2 
  Verifying        : postgresql-server-11.7-2.fc30.x86_64                                               2/2 
 
Installed:
  postgresql-plpython3-11.7-2.fc30.x86_64                postgresql-server-11.7-2.fc30.x86_64               
 
Complete!

While I thought this might fix the problem, it didn’t and raised the following error:

ERROR:  could not open extension control file "/usr/pgsql-11/share/extension/plpython3u.control": No such file or directory

I found the plpython3u.control file on GitHub and put the following plpython3u.control file, after comparing it against the plpgsql.control file, into the /usr/pgsql-11/share/extension directory. At this point, I began wondering why it’s looking in the /usr/pgsql-11/share/extension directory instead of a /usr/plpython3u/share/extension directory (does not exist).

# plpython3u extension
comment = 'PL/Python3U untrusted procedural language'
default_version = '1.0'
module_pathname = '$libdir/plpython3'
relocatable = false
schema = pg_catalog
superuser = true

I retried creating the plpython3u extension:

CREATE EXTENSION plpython3u;

It raised the following error:

ERROR:  extension "plpython3u" has no installation script nor update path for version "1.0"

At this point, I could find no further help on the Internet. I did notice that there were these two *.sql files in the /usr/pgsql-11/share/extension directory:

  • plpgsql–1.0.sql
  • plpgsql–unpackaged–1.0.sql

I found this plpython3u--1.0.sql file on GitHub:

/* src/pl/plpython/plpython3u--1.0.sql */
 
CREATE FUNCTION plpython3_call_handler() RETURNS language_handler
  LANGUAGE c AS 'MODULE_PATHNAME';
 
CREATE FUNCTION plpython3_inline_handler(internal) RETURNS void
  STRICT LANGUAGE c AS 'MODULE_PATHNAME';
 
CREATE FUNCTION plpython3_validator(oid) RETURNS void
  STRICT LANGUAGE c AS 'MODULE_PATHNAME';
 
CREATE LANGUAGE plpython3u
  HANDLER plpython3_call_handler
  INLINE plpython3_inline_handler
  VALIDATOR plpython3_validator;
 
COMMENT ON LANGUAGE plpython3u IS 'PL/Python3U untrusted procedural language';

I retried creating the plpython3u extension, as a member of the sudoer list and got a new error:

ERROR:  permission denied to create extension "plpython3u"
HINT:  Must be superuser to create this extension.

I retried creating the plpython3u extension as the postgres user, who is the owning user:

CREATE EXTENSION plpython3u;

It raised the following error:

ERROR:  could not access file "$libdir/plpython3": No such file or directory

While I intend to finish this, that’s as far as I got. It appears from some of the things I’ve read I need to recompile or configure items that would destabilize what I have working at the moment. Finishing this will need to wait for me to build another test environment from scratch. If you catch this post and know the remaining steps, I invite you to add them in the comments.

Posted by: , July 7, 2014

Question:

There should be more problems when trying to create the 5 extensions

$ psql  -U postgres book -c "CREATE EXTENSION tablefunc"
ERROR:  could not open extension control file "/usr/share/postgresql/9.3/extension/tablefunc.control": No such file or directory

How to Fix :

You can fix it by just downloading a package.

$ sudo apt-get install postgresql-contrib

Downloading the postgresql-contrib packages will give the ability to use the following five commands:

$ psql  -U postgres book -c "CREATE EXTENSION tablefunc"
$ psql  -U postgres book -c "CREATE EXTENSION hellopcduino"
$ psql  -U postgres book -c "CREATE EXTENSION ilovepcduino"
$ psql  -U postgres book -c "CREATE EXTENSION pcduinoisbest"
$ psql  -U postgres book -c "CREATE EXTENSION hellolinksprite"

And now you should be good to go!

Yang

Error:

[root@said extension]# su — postgres
Last login: Wed Dec 13 14:33:47 BDT 2017 on pts/1
-bash-4.2$ psql -U sors
psql (9.2.13, server 9.5.10)
WARNING: psql version 9.2, server version 9.5.
         Some psql features might not work.
Type «help» for help.

sors=# CREATE EXTENSION tablefunc;
ERROR:  could not open extension control file «/usr/pgsql-9.5/share/extension/tablefunc.control»: No such file or directory
sors=# exit
sors-# q
-bash-4.2$ exit

Reason: 


postgresql95-contrib package is not installed or wrong version installed


The 

tablefunc

 module includes various functions that return tables (that is, multiple rows). These functions are useful both in their own right and as examples of how to write C functions that return multiple rows.

Solution:

[root@said extension]# ls -lrt
total 12
-rw-r—r—. 1 root root 381 Nov  8 23:31 plpgsql—unpackaged—1.0.sql
-rw-r—r—. 1 root root 179 Nov  8 23:31 plpgsql.control
-rw-r—r—. 1 root root 332 Nov  8 23:31 plpgsql—1.0.sql
[root@said extension]# pwd

root@said yum.repos.d]# yum install postgresql-contrib
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
—> Running transaction check
—> Package postgresql95-contrib.x86_64 0:9.5.10-1PGDG.rhel7 will be installed
—> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================
 Package                                              Arch                                   Version                                             Repository                              Size
==============================================================================================================================================================================================
Installing:
 postgresql95-contrib                                 x86_64                                 9.5.10-1PGDG.rhel7                                  pgdg95                                 533 k

Transaction Summary
==============================================================================================================================================================================================
Install  1 Package
.

Total download size: 533 k
Installed size: 1.8 M
Is this ok [y/d/N]: y
Downloading packages:
postgresql95-contrib-9.5.10-1PGDG.rhel7.x86_64.rpm                                                                                                                     | 533 kB  00:00:01   
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : postgresql95-contrib-9.5.10-1PGDG.rhel7.x86_64                                                                                                                             1/1
  Verifying  : postgresql95-contrib-9.5.10-1PGDG.rhel7.x86_64                                                                                                                             1/1

Installed:
  postgresql95-contrib.x86_64 0:9.5.10-1PGDG.rhel7                                                                                                                                           

Complete!

[root@said yum.repos.d]# cd /usr/pgsql-9.5/share/extension/
[root@said extension]# ls -lrt
total 932
-rw-r—r—. 1 root root   394 Nov  8 23:31 timetravel—unpackaged—1.0.sql
-rw-r—r—. 1 root root   156 Nov  8 23:31 timetravel.control
-rw-r—r—. 1 root root   486 Nov  8 23:31 timetravel—1.0.sql
-rw-r—r—. 1 root root   134 Nov  8 23:31 tcn.control
-rw-r—r—. 1 root root   274 Nov  8 23:31 tcn—1.0.sql
-rw-r—r—. 1 root root  1160 Nov  8 23:31 tablefunc—unpackaged—1.0.sql
-rw-r—r—. 1 root root   174 Nov  8 23:31 tablefunc.control
-rw-r—r—. 1 root root  2153 Nov  8 23:31 tablefunc—1.0.sql

[root@said extension]# su — postgres
Last login: Wed Dec 13 14:55:33 BDT 2017 on pts/1
-bash-4.2$ psql  -U sors sors -c «CREATE EXTENSION tablefunc»
CREATE EXTENSION
-bash-4.2$ pwd
/var/lib/pgsql

Using mac OSX Yosemite 10.10.1. I uninstalled and re-installed both postgres and postgis with homebrew. I understand that postgres is looking in the wrong place for the postgis control file. Also noticed that ‘which psql’ path seems incorrect. How/where do I fix this?

psql

(9.4.0, server 9.3.5)

ERROR:  could not open extension control file "/usr/local/Cellar/postgresql/9.3.5_1/share/postgresql/extension/postgis.control": No such file or directory

find /usr -name postgis.control

/usr/local/Cellar/postgresql/9.4.0/share/postgresql/extension/postgis.control

which psql

/usr/local/bin/psql

which pg_config

/usr/local/bin/pg_config

brew info postgis

postgis: stable 2.1.5, HEAD
http://postgis.net
/usr/local/Cellar/postgis/2.1.5 (45 files, 8.6M) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/postgis.rb

brew info postgres

postgresql: stable 9.4.0 (bottled)
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.4.0 (3049 files, 74M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/postgresql.rb

Both .bashrc and .bash_profile have

export PGDATA='/usr/local/Cellar/postgresql/9.4.0/bin/postgres'
alias postgres-log='cd /usr/local/var/postgres/ && subl server.log'

mdfind -name «postgres» | grep -G «postgres$»

/usr/local/Cellar/postgresql/9.4.0/bin/postgres
/usr/local/var/postgres
/Users/lionelramos/macports/var/macports/sources/rsync.macports.org/release/tarballs/ports/ruby/rb-postgres

Looks like I have different a local version of postgres in addition to the homebrew version.

I was trying to run the following command but i threw me any error.

template1=# CREATE EXTENSION hstore

ERROR: could not open extension control file "usr/share/postgreesql/9.2/extension/hstore.control": No such file or directory 

It seems like I need to download the postgres-devel packages, but I don’t know exactly what I am missing. I installed my postgres with this command so I thought everything I need would be included together.

sudo apt-get install postgres-9.2 

Any help will be appreciated. Thank you.

Mitch's user avatar

Mitch

105k23 gold badges206 silver badges265 bronze badges

asked Oct 7, 2013 at 6:11

CYC0616's user avatar

The hstore extension, as well as many other extensions such as cube, fuzzystrmatch, uuid-ossp, etc., are packaged in postgresql-contrib, which you can install for your PostgreSQL version using:

sudo apt-get install postgresql-contrib-9.2

On a standard Ubuntu install,

sudo apt-get install postgresql postgresql-contrib

will install PostgreSQL with its contributed extensions.

answered Oct 7, 2013 at 7:18

zwets's user avatar

zwetszwets

11.5k2 gold badges31 silver badges44 bronze badges

Понравилась статья? Поделить с друзьями:
  • Error could not open c program files java jre7 lib i386 jvm cfg что делать
  • Error could not open c program files java jre7 lib amd64 jvm cfg
  • Error could not lock config file c program files git etc gitconfig permission denied
  • Error could not locate the bindings file tried
  • Error could not locate dkms conf file