PostGIS plugin for asdf version manager
IMPORTANT: This is a temporary plugin to allow installs with asdf v0.17+ until the postgis install is fixed in @knu's repo. It will be removed once this PR is merged.
This requires brew if you're on macOS, or a Debian flavored Linux. If you need it to work on something else, you'll likely need to modify the plugin. According to PostGIS installation page, you will need GEOS, Proj, GDAL, SFGCGAL, LibXML2, JSON-C, protobuf-c, etc. Finally, you will need a working installation of PostgreSQL including server headers. See asdf-postgres for the asdf plugin.
-
You will need a compiler.
-
macOS
gcc
- Hit the ok button and it will install. If it already has it, then you are good.
-
Ubuntu/Debian Linux
sudo apt-get install linux-headers-$(uname -r) build-essential
-
-
You will need these depencies installed.
-
macOS
brew install geos proj gdal sfcgal libxml2 json-c protobuf-c
-
Ubuntu/Debian Linux
sudo apt install gettext libproj-dev libgdal-dev libsfcgal-dev libgeos-dev \ libxml2-dev libxml2-utils docbook-xsl-ns xsltproc libjson-c-dev \ libprotobuf-c-dev protobuf-c-compiler
-
asdf plugin add postgis https://github.com/frm/asdf-postgis.git
# if running asdf pre v0.17, use this instead:
asdf plugin-add postgis https://github.com/frm/asdf-postgis.git
For mise, this plugin is listed in the official registry and you don't need to manually install it. Just run mise install postgis 3.2
, which will work.
Check asdf readme for instructions on how to install & manage versions of Postgres.
When installing PostGIS using asdf install
, you can pass custom configure options with the following env vars:
POSTGIS_CONFIGURE_OPTIONS
- use only your configure optionsPOSTGIS_EXTRA_CONFIGURE_OPTIONS
- append these configure options along with ones that this plugin already uses
asdf-postgis is aware of asdf-postgres and properly installs PostGIS to the currently selected PostgreSQL installation.
- Create your .tool-versions file in the project that needs PostGIS and add
postgis 2.3.2
or whatever version that you want. - run
asdf install
- Connect to your DB:
psql default
(or whatever name you gave your DB) CREATE EXTENSION postgis;
(Ditto forpostgis_topology
,postgis_raster
, etc. if you need them)
- Just
DROP EXTENSION postgis;
-
Run
asdf uninstall postgis
. However, this does not really uninstall PostGIS because the PostGIS runtime files are in the library directory of the PostgreSQL installation. -
Make sure you've dropped PostGIS extensions from all databases, and locate the runtime files by the following command.
find "$(pg_config --pkglibdir)" -maxdepth 1 \( -name '*postgis*' -or -name 'address_standardizer*' \)
-
If the list looks good, delete them.
find "$(pg_config --pkglibdir)" -maxdepth 1 \( -name '*postgis*' -or -name 'address_standardizer*' \) -delete
- If you want to install the same version of PostGIS to multiple PostgreSQL instances, the second attempt is blocked by
postgis X.Y.Z is already installed
. In that case, runasdf uninstall postgis X.Y.Z
and retry.