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

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>'

当我试图删除并重新创建我的 Rails-PostgreSQL

时突然出现上述错误

您可能最近升级了 boost Homebrew 公式,执行 brew update / brew upgrade,最新版本似乎不能很好地与 postgis 配合使用。

我通过返回 boost 的先前版本解决了一个非常相似的问题:

brew switch boost 1.58.0

UPDATE:既然这已在 Homebrew 中修复,下面建议进行简单更新/升级的答案可能是可行的方法。如果你之前做过切换,你现在可以brew switch boost 1.59.0升级到最新版本boost,你可能还需要brew reinstall postgis.

如果您需要安装特定版本的公式,请查看此主题:

Homebrew: install specific version of formula

也找不到 1.58.0,但是 1.55.0_1 可用并为我成功安装了 postgis。 effectif and Whosebug 中的这些条目非常有帮助。该过程可能有额外的步骤。

只是为了确定:

$ brew uninstall postgis

点击自制版本,如果还没有的话:

$ brew tap homebrew/versions

找到最新可用的:

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

这会在不同的公式 (boost155) 下安装 boost。为了能够切换版本,我将旧版本符号链接到 boost 目录:

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

之后一切照常:

$ brew switch boost 1.55.0_1
$ brew install postgis

我也 运行 遇到了这个问题,boost 的 1.56.0 版本可用并为我解决了这个问题。看起来问题出在 1.58.0.

这个issue has been fixed here。重新安装应该可以了。

    $ brew update && upgrade
    $ brew install postgis