![Postgres gem 无法安装在 12.10 上](https://linux22.com/image/827906/Postgres%20gem%20%E6%97%A0%E6%B3%95%E5%AE%89%E8%A3%85%E5%9C%A8%2012.10%20%E4%B8%8A.png)
我正在尝试在我的计算机上运行 Ruby on Rails,但 pg gem 总是失败。我发现很多其他问题都说你只需要使用libpq-dev
来自的包apt
就可以解决问题,但它仍然说找不到库。
nicholas@nick-ubuntu:~$ gem instal pg -- --with-pq-lib=/usr/lib
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/nicholas/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb --with-pq-lib=/usr/lib
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/nicholas/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
Gem files will remain installed in /home/nicholas/.rvm/gems/ruby-1.9.3-p327/gems/pg-0.14.1 for inspection.
Results logged to /home/nicholas/.rvm/gems/ruby-1.9.3-p327/gems/pg-0.14.1/ext/gem_make.out
答案1
不久前,我发现我必须使用 ruby-pg gem 来代替 pg gem,因为 pg gem 是不必要的。另外,避免使用旧的 postgres gem。
答案2
尝试安装以下软件包:
postgresql
和libpq-dev
。
这会让 pg gem 在 11.10、12.04 和 12.10 上为我编译本机扩展。
答案3
我有同样的问题。
安装postgresql
并对libpq-dev
我来说也起了作用。