Skip to content

Instantly share code, notes, and snippets.

@ascendbruce
Last active August 13, 2020 19:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ascendbruce/f20e17f07b7c8fa8b1bb9b2ef59ce46d to your computer and use it in GitHub Desktop.
Save ascendbruce/f20e17f07b7c8fa8b1bb9b2ef59ce46d to your computer and use it in GitHub Desktop.
error when rake db:migrate with postgresql 9.6 and postgis 2.4. error message Server is version 9.6, library is version 10.0

error message

PG::InternalError: ERROR:  incompatible library "/usr/local/lib/postgresql/postgis-2.4.so": version mismatch
DETAIL:  Server is version 9.6, library is version 10.0.
: CREATE EXTENSION IF NOT EXISTS "postgis"
/Users/bruce/Projects/HB-Backend/db/migrate/20151013213623_enable_postgis.rb:3:in `change'
-e:1:in `<main>'

Caused by:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  incompatible library "/usr/local/lib/postgresql/postgis-2.4.so": version mismatch
DETAIL:  Server is version 9.6, library is version 10.0.
: CREATE EXTENSION IF NOT EXISTS "postgis"

inspect current status

brew info postgresql
brew info postgis
psql --version
which psql

try 0: restart servers

  1. restart with homebrew
    brew services restart postgresql
    
  2. restart with pg_ctl
    pg_ctl -D /usr/local/var/postgres stop
    pg_ctl -D /usr/local/var/postgres start
    
  3. restart your Mac

ref: https://stackoverflow.com/questions/7975556/how-to-start-postgresql-server-on-mac-os-x

try 1: switch to old brew

brew info postgis

# if found old versions:
brew switch postgis 2.4.4_1

try 2: reinstall postgis

brew reinstall postgis

ref: Homebrew/legacy-homebrew#46358

try 3: install homebrew in history

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aa049a47b218fda30f9a4a454119ae067a02cf50/Formula/postgis.rb

after this, the error message changed but I didn't record it down.

ref:

try 4: build postgis from source (this works for my case)

download source from https://postgis.net/install/

in my case, it's postgis-2.4.4.tar.gz

# change path accordingly

brew unlink postgis

tar zxf postgis-2.4.4.tar.gz
cd postgis-2.4.4
./configure --with-pgconfig=/usr/local/Cellar/postgresql/9.6.2/bin/pg_config --with-xml2config=/usr/local/Cellar/libxml2/2.9.7/bin/xml2-config
make
make install

ref:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment