安装pg(1.0.0)时出错,Bundler无法继续
我有一个捆绑安装的问题,无法完成安装。
我能做些什么来完成捆绑包?
find_executable: checking for pg_config... -------------------- no
--------------------
find_header: checking for libpq-fe.h... -------------------- no
"clang -o conftest -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0/x86_64-darwin17 -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0/ruby/backward -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0 -I. -I/Users/leotyndall/.rbenv/versions/2.4.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/leotyndall/.rbenv/versions/2.4.2/lib -L. -L/Users/leotyndall/.rbenv/versions/2.4.2/lib -fstack-protector -L/usr/local/lib -lruby-static -framework CoreFoundation -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"clang -E -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0/x86_64-darwin17 -
I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-
2.4.0/ruby/backward -
I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0 -I. -
I/Users/leotyndall/.rbenv/versions/2.4.2/include -D_XOPEN_SOURCE -
D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-
error=shorten-64-to-32 -pipe conftest.c -o conftest.i"
conftest.c:3:10: fatal error: 'libpq-fe.h' file not found
#include <libpq-fe.h>
^~~~~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
/* end */
--------------------
extconf failed, exit code 1
An error occurred while installing pg (1.0.0), and Bundler cannot continue.
Make sure that `gem install pg -v '1.0.0'` succeeds before bundling.
尝试安装libpq-dev
或其等效的OS:
sudo apt-get install libpq-dev
brew安装postgresql
gem install pg----with pg-config=/select/local/lib/postgreql[版本号]/bin/pg_config
zypper
对于macos来说,上面的答案对我来说不起作用或者不实用。我不想安装所有的postgres。
$ brew install libpq
$ bundle config --local build.pg --with-opt-dir="/usr/local/opt/libpq"
$ bundle install
参考:https://michaelrigart.be/install-pg-ruby-gem-without-postgresql/
我通过安装库解决了这个问题
brew安装libpqxx
接下来正常安装pg…就可以使用gem了
gem install pg