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

obj*_*jah 8 ruby postgresql gem centos5 pg

在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
Run Code Online (Sandbox Code Playgroud)

但当我试图为红宝石安装'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.
Run Code Online (Sandbox Code Playgroud)

在尝试使用另一个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)
Run Code Online (Sandbox Code Playgroud)

locate libpq.so.4
/usr/lib/libpq.so.4
/usr/lib/libpq.so.4.1
Run Code Online (Sandbox Code Playgroud)

还出口路径

LD_LIBRARY_PATH=/usr/pgsql-9.0/lib
export LD_LIBRARY_PATH
Run Code Online (Sandbox Code Playgroud)

用"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'
Run Code Online (Sandbox Code Playgroud)

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

Mic*_*ohl 6

有各种不同的配置选项,你可以添加到创业板安装,如-with-opt-dir,--with-pg-dir--with-pg-config.看看这个邮件列表主题:

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


小智 5

$ gem --version
1.3.7

$ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]

$ cat /etc/redhat-release 
CentOS release 5.4 (Final)

$ uname -m
x86_64

sudo yum list installed | grep postgre    (see what you have installed)
sudo yum list available | grep postgre    (I was missing postgresql-devel)
sudo yum install postgresql-devel         (I installed it)
sudo gem install pg                       (no error this time!)

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