我正在尝试在本地使用 PostgreSQL 在 Ruby on Rails 中进行开发,因此我正在尝试安装 pg gem。在 Ubuntu 12.04 上。在终端中,我输入:
gem install pg -v '0.12.2'
这会引发以下错误:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/troyshu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
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/troyshu/.rvm/rubies/ruby-1.9.3-p194/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/troyshu/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.14.1 for inspection.
Results logged to /home/troyshu/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.14.1/ext/gem_make.out
有趣的是,在命令中添加 sudo 可以:
$ sudo gem install pg -v '0.12.2'
Building native extensions. This could take a while...
Successfully installed pg-0.12.2
1 gem installed
顺便说一句,我必须运行“sudo apt-get install ruby1.9.1-dev”才能使上述命令正常工作。但我仍然无法进行任何开发,因为“捆绑安装”不起作用(并且一直告诉我运行“gem install pg -v '0.12.2')
我有一种感觉“gem install pg”被绊倒了
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
但是,作为 Ubuntu 和 RoR 的新手,我不知道为什么。也许我的搜索技巧也很糟糕,因为我无法找到解决我的特殊情况的方法。希望有一个修复?
谢谢!