Мой проект Ruby On Rails не может установить gem postgre в CentOS 6.2

#ruby-on-rails #linux #postgresql #centos

#ruby-on-rails #linux #postgresql #centos

Вопрос:

Хотя многие источники ссылок из stackoverflow, но моя проблема не решена. Когда я запускаю свой проект (ProjectJapanFull_New) на window server, это не проблема, но когда я переключил его на CentOS server 6.2, возникает ошибка, а именно:

 [root@links02 ProjectJapanFull_New]# rails -v
You have requested:
  pg >= 0

The bundle currently has pg locked at 0.17.0.
Try running `bundle update pg`
Run `bundle install` to install missing gems.
  

Затем я запускаю: bundle install отображается еще одна ошибка:

 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-1.9.3-p547/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=/usr/local/rvm/rubies/ruby-1.9.3-p547/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib

extconf failed, exit code 1

Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p547/gems/pg-0.17.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p547/extensions/x86_64-linux/1.9.1/pg-0.17.0/gem_make.out
An error occurred while installing pg (0.17.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.0'` succeeds before bundling.
  

Когда я запускаю gem install pg -v '0.17.0' , отображается эта ошибка:

 [root@links02 ProjectJapanFull_New]# gem install pg -v '0.17.0'
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-1.9.3-p547/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=/usr/local/rvm/rubies/ruby-1.9.3-p547/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib

extconf failed, exit code 1

Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p547/gems/pg-0.17.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p547/extensions/x86_64-linux/1.9.1/pg-0.17.0/gem_make.out
  

Комментарии:

1. Попробуйте дать эту команду sudo apt-get install libpq-dev

2. Если это не сработает .. попробуйте это gem install pg -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config

3. @Pavan, это CENTOS, так что, вероятно sudo yum install libpq-dev

4. @RubyRacer Да! Вы правы.

5. Спасибо всем. Я попробовал это, но это не сработало, и когда я пытаюсь создать новый проект: ‘$ rails new myapp —database = postgresql’ => Can't find the 'libpq-fe.h header when trying to install pg gem , но я не могу запустить ` yum install postgresql-devel ,