Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostGIS Homebrew installation referencing an old path?

I upgraded and subsequently reinstalled PostGIS & PostgreSQL on OS X Mountain Lion. When trying to use the PostGIS extensions, I receive the following error:

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

It appears that PostGIS (and PostgreSQL as well??) are still looking for the required files in the /postgresql/9.2.3/ directory and not in the /postgresql/9.2.4/ directory. I have used Homebrew to remove all previous versions of PostgreSQL via the following command:

brew remove --force postgresql

Could someone please point me in the right directions as to why this problem is occurring? (There must be a lingering config file somewhere or something?)

Any help will be much appreciated.

like image 281
paddleman Avatar asked Apr 28 '13 16:04

paddleman


3 Answers

The problem is you have a psql server running on version 9.2.3 of the codebase. To test for this, load up a psql console and you should see this at the top:

psql (9.2.4, server 9.2.3)
Type "help" for help.

Note the "server 9.2.3" comment above. If you're running the proper version of your server, you would see this instead:

psql (9.2.4)
Type "help" for help.

To fix this, just follow the instructions given by brew info postgresql on unloading and loading the LaunchAgent - this will restart the server with the new code:

To reload postgresql after an upgrade:
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
like image 165
Empact Avatar answered Oct 26 '22 21:10

Empact


In terminal, I ran

$ psql

In psql, it showed me this

> psql (9.6.3, server 9.5.7)
> Type "help" for help.

I tried to run the following

> CREATE EXTENSION postgis;

and got this error message

> ERROR:  could not open extension control file "/usr/local/Cellar/[email protected]/9.5.7/share/[email protected]/extension/postgis.control": No such file or directory

I quit psql by

> \q

And then ran

$ brew services list

Which then came back with the following results

Name           Status  User     Plist
mysql          stopped          
[email protected]      stopped          
postgresql     stopped          
[email protected] started doquyena /Users/doquyena/Library/LaunchAgents/[email protected]
redis          stopped  

I worked out that my psql was running on an incompatible psql server so I corrected it with the following command

$ brew services stop [email protected]
$ brew services start postgresql

When I went back into psql

$ psql

It now displayed this which indicates that I was now on a matching server

> psql (9.6.3)
> Type "help" for help.

Hence, there was no error message when I then tried to create the extension again

> CREATE EXTENSION postgis;

And then I was able to create postgis data tables like this one without any problems

> CREATE TABLE s_test(geom geometry);
like image 21
Gwen Au Avatar answered Oct 26 '22 19:10

Gwen Au


Homebrew's design is to generally leave user-editable config files and generated data files in place during a remove or upgrade, so they're preserved between versions. Sounds like you're right and it's a config file left somewhere.

There are no global config files for postgres in /usr/local/etc. So it's probably user data files. Did you create any databases using the previous version of postgres and use the postgis extension in them? The config files in those databases may be referring to that old postgres version. Those databases are typically under /usr/local/var/postgres. Have a look at the .conf files under there and see if you can edit them to fix the extension path or re-create the databases.

like image 27
Andrew Janke Avatar answered Oct 26 '22 21:10

Andrew Janke