PostGIS Homebrew installation referencing the old path?

I updated and subsequently reinstalled PostGIS and PostgreSQL on OS X Mountain Lion. When I try to use PostGIS extensions, I get 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 looks like PostGIS (and PostgreSQL too?) Are still looking for the required files in the /postgresql/9.2.3/ directory, and not in the /postgresql/9.2.4/ directory. I used Homebrew to uninstall all previous versions of PostgreSQL with the following command:

 brew remove --force postgresql 

Can someone please give me the correct directions as to why this problem occurs? (Should there be some lingering configuration file somewhere or something?)

Any help would be greatly appreciated.

+6
source share
4 answers

The problem is that you have a psql server running on codebase version 9.2.3. To check this, download the psql console and you will see it at the top:

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

Pay attention to the comment "server 9.2.3" above. If you are using the correct version of your server, you will see this instead:

 psql (9.2.4) Type "help" for help. 

To fix this, simply follow the instructions provided by brew info postgresql when unloading and loading LaunchAgent - this will restart the server using 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 
+12
source

The Homebrew design typically leaves user-editable configuration files and generated data files in place during remove or upgrade , so they are saved between versions. It seems that you are right, and somewhere the configuration file remained.

There are no global configuration files for postgres in /usr/local/etc So these are probably user data files. Have you created databases using the previous version of postgres and used the postgis extension? The configuration files in these databases may reference this old version of postgres. These databases are usually located under /usr/local/var/postgres . Look at the .conf files there and see if you can edit them to fix the extension path or recreate the databases.

+1
source

I faced the same problem and after these solutions did not fix it, I found one of mine:

 brew uninstall postgis && brew install postgis 

The key to this work stood out to me in the build output for postgis:

 ==> ./configure --with-projdir=/usr/local --with-jsondir=/usr/local/opt/json-c --with-pgconfig=/usr/local/Cellar/postgresql/9.4.4/bin/pg_config --disable-nls 

Note that it uses pg_config, most likely to determine where it should store all the files needed for the extension.

+1
source

In the terminal, I ran

 $ psql 

In psql he 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/ postgresql@9.5 /9.5.7/share/ postgresql@9.5 /extension/postgis.control": No such file or directory 

I exit psql on

 > \q 

And then ran

 $ brew services list 

who then returned with the following results

 Name Status User Plist mysql stopped mysql@5.6 stopped postgresql stopped postgresql@9.5 started doquyena /Users/doquyena/Library/LaunchAgents/ homebrew.mxcl.postgresql@9.5.plist redis stopped 

I realized that my psql is running on an incompatible psql server, so I fixed it with the following command

 $ brew services stop postgresql@9.5 $ brew services start postgresql 

When I returned to psql

 $ psql 

Now it displays this, which indicates that I was now on the corresponding server

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

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

 > CREATE EXTENSION postgis; 

And then I managed to create postgis data tables like this without any problems

 > CREATE TABLE s_test(geom geometry); 
+1
source

Source: https://habr.com/ru/post/943822/


All Articles