Skip to content

Add PostGIS to the embedded Postgres

fcdev runs a self-contained PostgreSQL that it downloads on first start. That distribution is a plain PostgreSQL build: it has the standard contrib extensions (hstore, pg_trgm, bloom and the rest) but not PostGIS. On macOS and glibc Linux, one command adds it:

Terminal window
fcdev install postgis

Then, in the database that needs it:

CREATE EXTENSION postgis;

While PostGIS is not installed, fcdev start starts as always and logs one warning that says so. On Windows and Alpine (musl) Linux there is no add-on build: use the manual procedure below.

The platform itself never needs PostGIS (it uses no PostgreSQL extensions at all); this page is only about databases your application keeps on the embedded server.

The command downloads the PostGIS add-on that your fcdev pins, checks its SHA-256 against the value compiled into fcdev (a mismatch installs nothing), and unpacks it into the embedded server’s tree. The add-on is built from source for the embedded server’s binaries by the platform repository’s release workflow and published as a release asset.

Platform Add-on
macOS, Apple Silicon darwin-arm64, built for macOS 13 or later
macOS, Intel darwin-amd64, built for macOS 13 or later
Linux x86_64, glibc linux-amd64, glibc 2.27 or later
Linux arm64, glibc linux-arm64, glibc 2.27 or later
Linux musl (Alpine), Windows, others none: by hand

It carries PostGIS 3.6.4, the core postgis extension only (no raster, topology, SFCGAL, tiger geocoder or address standardizer), for PostgreSQL 18, with everything it needs: GEOS, PROJ (and proj.db), SQLite, json-c, libxml2 and protobuf-c. It uses nothing else on the machine: no Homebrew, apt packages or PostgreSQL of your own.

  • If the embedded tree does not exist yet, the command fetches it first, as fcdev start would.
  • It refuses when the tree’s server is not the PostgreSQL major the add-on is for.
  • Running it again when that add-on is installed does nothing and says so. Two installs never run at once.
  • While fcdev is running. A first install works at once, because PostgreSQL reads an extension’s files when CREATE EXTENSION runs. When the command replaces a PostGIS the running server may already have loaded (an earlier add-on, or one copied in by hand), it tells you to restart fcdev (fcdev stop, then fcdev). After a version change, run ALTER EXTENSION postgis UPDATE; in each database that has it.
  • If the install fails part way, fcdev start says the tree is incomplete; run the command again.
  • fcdev install postgis --archive <tarball> installs an add-on you built yourself, instead of the pinned release. It must name your platform and fcdev’s PostgreSQL major, and has no checksum to check it against.
  • An fcdev built before an add-on release was pinned says that it has none; use the manual procedure.

Every fcdev on the machine uses the same tree.

What survives what. Data wipes (fcdev --embedded-db-reset, fcdev db upgrade, fcdev fresh) touch the data only, never the tree: PostGIS stays installed, and a fresh database needs CREATE EXTENSION postgis; again. Deleting the cache directory brings the warning back; run the command again. A newer fcdev that pins a newer add-on says so on start; run the command to update.

Gotchas. If PROJ_DATA or PROJ_LIB is set in fcdev’s environment, PROJ looks there for proj.db before the add-on’s copy, and a proj.db of another PROJ version can fail transformations; the same goes for a proj.db in PROJ’s user directory (~/.local/share/proj, or ~/Library/Application Support/proj on macOS). Unset the variable for fcdev, or remove that file. An Intel fcdev on Apple Silicon (under Rosetta) installs the darwin-amd64 add-on, which is not tested: use the arm64 fcdev.

By hand: platforms the add-on does not cover

Section titled “By hand: platforms the add-on does not cover”

PostGIS is “just files”, though: a loadable module plus its extension SQL and control files. For Windows, Alpine (musl) Linux, an fcdev with no add-on pinned, or an extension the add-on leaves out (raster, topology), copy a matching PostGIS build into the embedded tree yourself, restart fcdev, and run CREATE EXTENSION postgis. fcdev start recognises a hand-copied PostGIS (by its postgis.control) and does not warn; fcdev install postgis replaces it.

  1. The PostgreSQL major: 18. fcdev pins the embedded server to PostgreSQL 18. A PostGIS built for another major fails to load with undefined symbol or incompatible library. Check against the embedded binary, not a system PostgreSQL you may also have.

  2. OS, CPU architecture and C library of the embedded build:

    Your machine Embedded build Install PostGIS for
    macOS, Apple Silicon darwin-arm64v8 macOS arm64
    macOS, Intel darwin-amd64 macOS x86_64
    Linux x86_64, glibc linux-amd64 Linux amd64
    Linux x86_64, musl (Alpine) linux-amd64-alpine Alpine amd64
    Linux arm64, glibc linux-arm64v8 Linux arm64
    Windows x64 windows-amd64 Windows x64
    Windows on ARM none (run the x64 fcdev under emulation) Windows x64
  3. PostGIS’s own dependencies stay installed (GEOS, PROJ, GDAL, libxml2, protobuf-c): the module links against them when it loads.

  4. Do it after the first start, so the tree exists, then restart fcdev.

The binaries live in the user cache directory, under flowcatalyst/embedded-pg/bin (which holds bin/, lib/ and share/):

OS Path
macOS ~/Library/Caches/flowcatalyst/embedded-pg/bin
Linux ~/.cache/flowcatalyst/embedded-pg/bin (or under $XDG_CACHE_HOME)
Windows %LOCALAPPDATA%\flowcatalyst\embedded-pg\bin

On macOS and Linux, set variables for the module and extension directories (anchored on plpgsql, so the exact layout does not matter):

Terminal window
EMBED=~/Library/Caches/flowcatalyst/embedded-pg/bin # Linux: ~/.cache/flowcatalyst/embedded-pg/bin
"$EMBED/bin/postgres" --version # must say: postgres (PostgreSQL) 18.x
file "$EMBED/bin/postgres" # confirms the architecture
MODDIR=$(dirname "$(find "$EMBED/lib" -name 'plpgsql.*' | head -1)")
EXTDIR=$(dirname "$(find "$EMBED/share" -name 'plpgsql.control' | head -1)")
echo "modules -> $MODDIR"; echo "extensions -> $EXTDIR"

Modules are .dylib files on macOS and .so files on Linux.

On Windows (PowerShell):

Terminal window
$Embed = "$env:LOCALAPPDATA\flowcatalyst\embedded-pg\bin"
& "$Embed\bin\postgres.exe" --version # postgres (PostgreSQL) 18.x
$ModDir = "$Embed\lib"
$ExtDir = (Get-ChildItem "$Embed\share" -Recurse -Filter plpgsql.control).Directory.FullName

Homebrew’s postgis carries builds for several PostgreSQL majors at once, so point at the one for 18:

Terminal window
brew install postgis # pulls in GEOS, PROJ and GDAL
PGMAJ=18
SRC_MOD="$(brew --prefix)/lib/postgresql@${PGMAJ}"
SRC_EXT="$(brew --prefix)/share/postgresql@${PGMAJ}/extension"
# find -exec rather than globs: zsh aborts a command whose glob matches nothing
find "$SRC_MOD" \( -name 'postgis*-3.dylib' -o -name 'address_standardizer*-3.dylib' \) -exec cp {} "$MODDIR/" \;
find "$SRC_EXT" \( -name 'postgis*' -o -name 'address_standardizer*' \) -exec cp {} "$EXTDIR/" \;

Homebrew’s module refers to its dependencies by their Homebrew paths, so it keeps loading only while the geos, proj and gdal formulae stay installed. The embedded distribution has no psql; brew install libpq gives you one.

Use the PostgreSQL project’s apt repository (PGDG), which has PostGIS for PostgreSQL 18 on both architectures. The dependencies install system-wide, so the loader finds them.

Terminal window
sudo apt-get install -y curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc \
https://www.postgresql.org/media/keys/ACCC4CF8.asc
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] \
https://apt.postgresql.org/pub/repos/apt $(. /etc/os-release; echo $VERSION_CODENAME)-pgdg main" \
| sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update
sudo apt-get install -y postgresql-18-postgis-3
sudo find /usr/lib/postgresql/18/lib \( -name 'postgis*-3.so' -o -name 'rtpostgis*-3.so' -o -name 'address_standardizer*-3.so' \) -exec cp {} "$MODDIR/" \;
find /usr/share/postgresql/18/extension \( -name 'postgis*' -o -name 'address_standardizer*' \) -exec cp {} "$EXTDIR/" \;

On Alpine (musl) the embedded build is linux-amd64-alpine: install PostGIS for PostgreSQL 18 from Alpine’s repository and copy it the same way. Never put a glibc PostGIS into the musl build.

RHEL, Rocky and AlmaLinux (x86_64 and arm64)

Section titled “RHEL, Rocky and AlmaLinux (x86_64 and arm64)”
Terminal window
# PGDG repository for your release (EL9 x86_64 shown; use the aarch64 RPM on arm64)
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf -qy module disable postgresql
sudo dnf install -y postgis34_18 # postgis<version>_18: use the version available
sudo find /usr/pgsql-18/lib \( -name 'postgis*-3.so' -o -name 'rtpostgis*-3.so' -o -name 'address_standardizer*-3.so' \) -exec cp {} "$MODDIR/" \;
find /usr/pgsql-18/share/extension \( -name 'postgis*' -o -name 'address_standardizer*' \) -exec cp {} "$EXTDIR/" \;

Get the files from a PostgreSQL 18 PostGIS bundle: install PostgreSQL 18 (x64) from the EDB installer and add PostGIS for PostgreSQL 18 with Stack Builder (Spatial Extensions), or use the matching PostGIS zip from the PostGIS Windows downloads. Then:

Terminal window
$Src = "C:\Program Files\PostgreSQL\18"
# The modules
Copy-Item "$Src\lib\postgis*-3.dll","$Src\lib\rtpostgis*-3.dll","$Src\lib\address_standardizer*-3.dll" $ModDir
# The DLLs PostGIS depends on go next to postgres.exe, where the loader looks
Copy-Item "$Src\bin\*geos*.dll","$Src\bin\*proj*.dll","$Src\bin\*gdal*.dll","$Src\bin\libxml2*.dll","$Src\bin\*protobuf*.dll" "$Embed\bin"
# The extension SQL and control files
Copy-Item "$Src\share\extension\postgis*","$Src\share\extension\address_standardizer*" $ExtDir

If CREATE EXTENSION names a missing DLL, copy that DLL next to postgres.exe too.

Restart fcdev if it was running while you copied, then enable the extension in the database that needs it (default port 15432, user and password postgres), with the psql from the PostgreSQL 18 you installed:

Terminal window
psql "postgresql://postgres:postgres@localhost:15432/orders" \
-c "CREATE EXTENSION IF NOT EXISTS postgis;" \
-c "SELECT postgis_full_version();"
Action Effect
fcdev --embedded-db-reset Deletes the data directory, so every database and its registered extension. The copied files survive: run CREATE EXTENSION postgis again.
fcdev db upgrade Same as a reset for the extension (the cluster is re-initialised).
Deleting the cache directory fcdev downloads the plain binaries again; copy PostGIS again.
A new fcdev with a new PostgreSQL minor The binaries may be re-extracted; copy a matching PostGIS again.
A new PostgreSQL major in fcdev You need a PostGIS built for that major.
  • undefined symbol or incompatible library version on CREATE EXTENSION: the PostGIS is for the wrong PostgreSQL major or the wrong architecture.
  • Library not loaded / image not found: a dependency (GEOS, PROJ, GDAL) is not where the module expects it. Keep those packages installed (macOS, Linux) or copy the named DLL next to postgres.exe (Windows).
  • could not open extension control file: the extension files went to the wrong directory; check $EXTDIR.