Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostGIS Error - PG::InternalError: ERROR: could not load library

StandardError: An error has occurred, this and all later migrations canceled:

PG::InternalError: ERROR:  could not load library "/usr/local/Cellar/postgresql/9.4.5/lib/postgis-2.1.so": dlopen(/usr/local/Cellar/postgresql/9.4.5/lib/postgis-2.1.so, 10): Symbol not found: __ZN5boost7archive21basic_binary_iarchiveINS0_15binary_iarchiveEE13load_overrideERNS0_15class_name_typeEi
  Referenced from: /usr/local/lib/libSFCGAL.1.dylib
  Expected in: /usr/local/lib/libboost_serialization-mt.dylib
 in /usr/local/lib/libSFCGAL.1.dylib
: CREATE EXTENSION IF NOT EXISTS "postgis"/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  could not load library "/usr/local/Cellar/postgresql/9.4.5/lib/postgis-2.1.so": dlopen(/usr/local/Cellar/postgresql/9.4.5/lib/postgis-2.1.so, 10): Symbol not found: __ZN5boost7archive21basic_binary_iarchiveINS0_15binary_iarchiveEE13load_overrideERNS0_15class_name_typeEi
  Referenced from: /usr/local/lib/libSFCGAL.1.dylib
  Expected in: /usr/local/lib/libboost_serialization-mt.dylib
 in /usr/local/lib/libSFCGAL.1.dylib
: CREATE EXTENSION IF NOT EXISTS "postgis"
/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'
PG::InternalError: ERROR:  could not load library "/usr/local/Cellar/postgresql/9.4.5/lib/postgis-2.1.so": dlopen(/usr/local/Cellar/postgresql/9.4.5/lib/postgis-2.1.so, 10): Symbol not found: __ZN5boost7archive21basic_binary_iarchiveINS0_15binary_iarchiveEE13load_overrideERNS0_15class_name_typeEi
  Referenced from: /usr/local/lib/libSFCGAL.1.dylib
  Expected in: /usr/local/lib/libboost_serialization-mt.dylib
 in /usr/local/lib/libSFCGAL.1.dylib
/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'

Am getting the above error all of sudden when i tried to drop and recreate my Rails-PostgreSQL

like image 868
Harsha M V Avatar asked Nov 03 '15 05:11

Harsha M V


3 Answers

You probably recently upgraded the boost Homebrew formula doing a brew update / brew upgrade, and it seems the latest version is not playing well with postgis.

I fixed a very similar issue by going back to the previous version of boost with:

brew switch boost 1.58.0

UPDATE: now that this was fixed in Homebrew, the answer below suggesting to do a simple update / upgrade is probably the way to go. If you did switch previously, you can now brew switch boost 1.59.0 to upgrade to the latest version of boost, you might also have to brew reinstall postgis.

like image 185
Marco Avatar answered Nov 16 '22 23:11

Marco


This issue has been fixed here. Re-install and it should work.

    $ brew update && upgrade
    $ brew install postgis
like image 43
geoboy Avatar answered Nov 16 '22 23:11

geoboy


Couldn't find 1.58.0 either, but 1.55.0_1 is available and successfully installed postgis for me. These entries in effectif and stackoverflow were very helpful. The process may have extra steps.

Just to be sure:

$ brew uninstall postgis

Tap to homebrew versions, if not having it yet:

$ brew tap homebrew/versions

Find the newest available:

$ brew search boost
...
homebrew/versions/boost155
...
$ brew install homebrew/versions/boost155

This installs boost under a different formula (boost155). To be able to switch versions, I symlinked the old version to the boost directory:

$ ln -s /usr/local/Cellar/boost155/1.55.0_1 /usr/local/Cellar/boost/1.55.0_1 

After this it is business as usual:

$ brew switch boost 1.55.0_1
$ brew install postgis
like image 3
MiRin Avatar answered Nov 16 '22 23:11

MiRin