解决方案
卸载并重新安装sqlite:
~/d/w/r/my-app git:master ❯❯❯ gem uninstall sqlite3
Successfully uninstalled sqlite3-1.3.7
~/d/w/r/my-app git:master ❯❯❯ gem install sqlite3
Fetching: sqlite3-1.3.7.gem (100%)
Building native extensions. This could take a while...
Successfully installed sqlite3-1.3.7
1 gem installed
发生了什么
当安装sqlite3 gem时,它会构建一个用于与sqlite通信的本地组件,因此它链接到本地的sqlite3库。这一切都是由gem在幕后处理的。当这种情况发生时,它指定了所链接的库的位置。
最近(一月份),sqlite的homebrew公式变成了keg-only。以前链接到sqlite的任何内容都引用了homebrew版本。您可以使用otool -L
来检查这一点:
~/d/w/r/my-app git:master ❯❯❯ otool -L /path/to/earlier/gem/sqlite3-1.3.6/lib/sqlite3/sqlite3_native.bundle
/path/to/earlier/gem/sqlite3-1.3.6/lib/sqlite3/sqlite3_native.bundle:
/usr/local/lib/libsqlite3.0.8.6.dylib (compatibility version 9.0.0, current version 9.6.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
运行otool
命令,你可以看到新版本现在已经链接到了由苹果提供的系统sqlite库:
~/d/w/r/a/new-config git:master ❯❯❯ otool -L /path/to/new/gem/sqlite3-1.3.7/lib/sqlite3/sqlite3_native.bundle
/path/to/new/gem/sqlite3-1.3.7/lib/sqlite3/sqlite3_native.bundle:
/usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 9.6.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)