Resolving "ERROR: could not open extension control file" from "create extension postgis;' for PostgreSQL 10?

I found this question and answer on stackoverflow.com for PostgreSQL 9.6: https://stackoverflow.com/questions/42806784/how-to-alter-the-path-for-postgres-looking-for-extensions.

This answer also works for PostgreSQL 10.

I first moved all files from .\share\extension to .\share\postgresql\extension and re-ran the create extension postgis. As expected, I received this error: ERROR: could not access file "$libdir/postgis-2.5": No such file or directory. Which I figured, but I wanted to see what the exact error would be.

Then I moved the files in .\lib into .\lib\postgresql and now the create extension postgis works.


Download binary of the desired version of postgis and add extensions files in lib and share/extension folder of postgresql. Hopefully, this issue will be resolved.


The command below resolved my case:

sudo apt install postgresql-10-postgis-scripts