我正在使用 Ruby on Rails 3.1 预版本。我喜欢使用 PostgreSQL,但问题是安装pg
宝石。它给了我以下错误:
$ gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/u/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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
--without-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/u/.rvm/rubies/ruby-1.9.2-p0/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
Gem files will remain installed in /home/u/.rvm/gems/ruby-1.9.2-p0/gems/pg-0.11.0 for inspection.
Results logged to /home/u/.rvm/gems/ruby-1.9.2-p0/gems/pg-0.11.0/ext/gem_make.out
我该如何解决这个问题?
看起来在 Ubuntu 中,标头是libpq-dev package http://packages.ubuntu.com/natty/i386/libpq-dev/filelist(至少在以下 Ubuntu 版本中:11.04 http://en.wikipedia.org/wiki/List_of_Ubuntu_releases#Ubuntu_11.04_.28Natty_Narwhal.29(纳蒂独角鲸),10.04 https://en.wikipedia.org/wiki/List_of_Ubuntu_releases#Ubuntu_10.04_LTS_.28Lucid_Lynx.29(清醒山猫),11.10 http://en.wikipedia.org/wiki/List_of_Ubuntu_releases#Ubuntu_11.10_.28Oneiric_Ocelot.29(梦魇豹猫),12.04 http://en.wikipedia.org/wiki/List_of_Ubuntu_releases#Ubuntu_12.04_LTS_.28Precise_Pangolin.29(精准穿山甲),14.04 https://en.wikipedia.org/wiki/List_of_Ubuntu_releases#Ubuntu_14.04_LTS_.28Trusty_Tahr.29(值得信赖的塔尔)和18.04 https://en.wikipedia.org/wiki/Ubuntu_version_history#Ubuntu_18.04_LTS_(Bionic_Beaver)(仿生海狸)):
...
/usr/include/postgresql/libpq-fe.h
...
所以尝试安装libpq-dev
或您操作系统的同等版本:
- 对于 Ubuntu/Debian 系统:
sudo apt-get install libpq-dev
- On 红帽Linux http://en.wikipedia.org/wiki/Red_Hat_Linux(RHEL) 系统:
yum install postgresql-devel
- For Mac Homebrew https://en.wikipedia.org/wiki/Homebrew_%28package_management_software%29:
brew install postgresql
- For Mac MacPorts http://en.wikipedia.org/wiki/MacPortsPostgreSQL:
gem install pg -- --with-pg-config=/opt/local/lib/postgresql[version number]/bin/pg_config
- For OpenSuse https://en.wikipedia.org/wiki/OpenSUSE:
zypper in postgresql-devel
- For ArchLinux https://en.wikipedia.org/wiki/Arch_Linux:
pacman -S postgresql-libs
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)