ruby-on-rails - yml - rails new myapp postgresql
La instalación de la gema PostgreSQL con ''gem pq'' falla con ERROR: no se pudo construir la extensión nativa de la gema (3)
Estoy aprendiendo Ruby on Rails y tratando de desarrollar una aplicación. En mi aplicación, estoy tratando de usar la base de datos SQLite por defecto en el Modo de Desarrollo y PostgreSQL en el Modo de Producción . Pero recibo el siguiente error al intentar instalar la gema de pg usando: gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/tusharkhatiwada/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev
for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev
for building a client-side application.
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/tusharkhatiwada/.rvm/rubies/ruby-2.0.0-p247/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}/
Gem files will remain installed in /home/tusharkhatiwada/.rvm/gems/[email protected]/g
ems/pg-0.17.0 for inspection.
Results logged to /home/tusharkhatiwada/.rvm/gems/[email protected]/gems/pg-0.17.0/ext
/gem_make.out
Después de eso, intenté nuevamente con gem install pg -- --with-pg-config= ''/usr/bin/pg_config''
y se muestra el siguiente error:
Building native extensions with: ''--with-pg-config= /usr/bin/pg_config''
This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/tusharkhatiwada/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb --with-pg-config= /us
r/bin/pg_config
Using config values from
sh: 1: : Permission denied
sh: 1: : Permission denied
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/tusharkhatiwada/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
--with-pg
--without-pg
--with-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}/
Gem files will remain installed in /home/tusharkhatiwada/.rvm/gems/[email protected]/g
ems/pg-0.17.0 for inspection.
Results logged to /home/tusharkhatiwada/.rvm/gems/[email protected]/gems/pg-0.17.0/ext
/gem_make.out
Si está utilizando Ubuntu intente instalar el siguiente archivo lib
sudo apt-get install libpq-dev
y luego joya instalar pg
trabajó para mi.
Tienes que hacer esto
sudo apt-get install libgmp-dev libpq-dev
y entonces
gem install pg
para aquellos que llegaron a esta búsqueda en google si libpq-dev no funcionó o arrojó otros errores, tuve el mismo problema, intente actualizar su sistema y obtener el ruby div-kit
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install ruby1.9.1-dev
luego reinicia después de esto solo inténtalo de nuevo
...