升级后的pg_config,ruby pg,postgresql 9.0问题,centos 5

在postgresql 8.1升级到9.0之后,我发现了库依赖的问题。 Postgresql工作正常(连接,查询)。

yum list postgresql* Installed Packages postgresql.i386 9.0.0-1PGDG.el5 installed postgresql-debuginfo.i386 9.0.0-1PGDG.el5 installed postgresql-devel.i386 9.0.0-1PGDG.el5 installed postgresql-libs.i386 9.0.0-1PGDG.el5 installed postgresql-odbcng.i386 0.90.101-2.el5 installed postgresql-plruby.i386 0.5.1-5.el5 installed postgresql-server.i386 9.0.0-1PGDG.el5 install 

但当我试图为ruby安装’pg’时,我收到了

 gem install pg Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension. /usr/local/bin/ruby extconf.rb checking for pg_config... no 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. 

在尝试使用另一个ruby-postgres驱动程序时,我得到了

 yum install ruby-postgres ruby-postgres-0.7.1-5.el5.i386 from epel has depsolving problems --> Missing Dependency: libpq.so.4 is needed by package ruby-postgres-0.7.1-5.el5.i386 (epel) 

 locate libpq.so.4 /usr/lib/libpq.so.4 /usr/lib/libpq.so.4.1 

还出口路径

 LD_LIBRARY_PATH=/usr/pgsql-9.0/lib export LD_LIBRARY_PATH 

用“require pg”(在8.1上工作)运行ruby脚本之后,我得到了:

 /usr/local/lib/ruby/site_ruby/1.8/i686-linux/pg_ext.so: libpq.so.4: cannot open shared object file: No such file or directory - /usr/local/lib/ruby/site_ruby/1.8/i686-linux/pg_ext.so (LoadError) from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require' from /usr/local/lib/ruby/site_ruby/1.8/pg.rb:12 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require' 

有什么建议可以做更多吗?

您可以添加到gem安装中的各种配置选项,例如-with-opt-dir , – --with-pg-dir--with-pg-config 。 看看这个邮件列表线程:

http://www.ruby-forum.com/topic/409608

 $ gem --version
 1.3.7

 $ ruby​​ --version
 ruby 1.9.2p180(2011-02-18修订版30909)[x86_64-linux]

 $ cat / etc / redhat-release 
 CentOS版本5.4(最终版)

 $ uname -m
 x86_64的

 sudo yum list安装|  grep postgre(看看你安装了什么)
 sudo yum list available |  grep postgre(我失踪了postgresql-devel)
 sudo yum install postgresql-devel(我安装了)
 sudo gem install pg(这次没错!)

 $ gem list --local |  grep pg
第(0.11.0)页

这看起来像pg配置文件位置错误,

 gem install pg -- --with-pgsql-lib=/usr/pgsql-9.0/lib --with-pg-config=/usr/pgsql-9.1/bin/pg_config 

解决它!!

 gem install pg -- --with-pgsql-lib=/usr/pgsql-9.0/lib --with-pg-config=/usr/pgsql-9.1/bin/pg_config /usr/local/lib/ruby/1.9.1/yaml.rb:56:in `': It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. Building native extensions. This could take a while... Successfully installed pg-0.14.0 1 gem installed Installing ri documentation for pg-0.14.0... Installing RDoc documentation for pg-0.14.0... 

在Mac OSX 10.6.8上,使用Postgres 9的MacPorts安装,以下命令对我有用:

 gem install pg -- --with-pgsql-lib=/opt/local/lib/postgresql90/lib --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config 

libpq.so.4来自PostgreSQL的旧版本; 9.0附带/usr/pgsql-9.0/lib/libpq.so.5

如果你有一个针对libpq.so.4构建的程序,那么该文件由compat-postgresql-libs包提供,你可能没有安装它们。 很多人使用“–force”删除它,因为否则很难安装新的RPM; 这是一个坏主意,但替代方案很复杂 。 如果您已经安装了该软件包,那么您应该找到一个/usr/lib/libpq.so.4 ,它可以使您现有的程序(最初为较旧的PostgreSQL编译)感到高兴。