Se ha producido un error al instalar pg (0.17.1) y Bundler no puede continuar


Acabo de instalar Rails 4.0.2 y al crear una nueva aplicación, en la etapa de paquete obtengo:

Installing pg (0.17.1) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/Dee/.rvm/rubies/ruby-2.0.0-p247/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.

¿Cómo soluciono esto?

Author: Deekor, 2013-12-24

13 answers

Estoy en un Mac ejecutando Mavericks. Mi solución fue instalar Postgres.

Y luego en terminal install usando homebrew con la configuración:

gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config

Nota: Esta respuesta se ha editado para usar el enlace simbólico latest que se incluye actualmente en las versiones de envío de la aplicación Postgres.

Versiones anteriores sugeridas:

gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
 127
Author: Bob O'Brien,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-04 08:29:35

Se ha presentado algún tipo de error Instalando PG gem en OS X-fallo en la compilación de la extensión nativa

Para instalar dependencias en Ubuntu prueba esto:

sudo apt-get install libpq-dev

Y esto

gem install pg
 147
Author: Talgat Medetbekov,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:26:24

Raíz de la aplicación:

  1. actualización de brew
  2. instalación de cerveza postgres
  3. gem install pg with with-pg-config = /usr/local / Cellar/postgresql/9.3.4/bin/pg_config
  4. instalación del paquete
  5. ln-sfv /usr/local/opt/postgresql/*.plist ~ / Library / LaunchAgents
  6. launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
  7. createuser-s-r postgres
  8. rake db: create: all
  9. rake db: migrar
  10. rails s

NOTA: reemplace el número de versión en el paso 3 si es necesario.

 16
Author: knice,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-05-07 21:41:59

Respuesta que funcionaba previamente con una versión anterior

Instalé bajo mac OSX Mavericks, teniendo la aplicación postgres (Versión 9.2.2.0) desde www.postgresapp.com instalado. El problema subyacente era simpy que desde postgres se instaló a través de la aplicación, el archivo de configuración reside en una ubicación que no es la predeterminada cuando se instala sin postgressapp. así que tenemos que decirle a gem dónde encontrar este archivo por:

Instalar gema pg -- --with-pg-config= / Applications / Postgres.app / Contents/macOS/bin / pg_config

Espero que ayude

 11
Author: Robertibiris,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-23 19:01:13

Si la instalación de gem pg falla, pruebe el siguiente comando:

env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config

... desde el PostgreSQL.documentación de la aplicación

 5
Author: Vince,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-24 02:57:06

Parece que no tiene instalado PostgreSQL. La gema pg requiere algunas cabeceras de PostgreSQL para compilar la extensión nativa.

 3
Author: tungd,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-24 02:38:40

Tuve que combinar todo y usar

sudo env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
 3
Author: Mark Wang,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-28 16:28:31

Si está usando algo que no sea Postgres en desarrollo y Postgres solo en producción, puede agregar la gema pg a su gemfile de esta manera...

group :production do
  gem 'pg',             '0.17.1'
end

Luego use bundle install --without production

 1
Author: j8d,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-08-14 05:12:09

Para los usuarios de CentOS:

sudo yum install postgresql-devel

Y

gem install pg
 1
Author: webster,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-19 05:47:17

Después de instalar Postgres tuve que ejecutar el siguiente comando

env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config

Después de este paquete de instalación funciona muy bien!

Espero que ayude

 0
Author: pochocosta,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-11-02 01:26:52

La forma en que logré superar ese error fue:

  • cd a la carpeta app y luego establecer la versión de ruby localmente. Estoy usando ruby 2.1.2.

Rbenv local 2.1.2

  • en lugar de solo ejecutar bundle install, instale las gemas en vendor / bundle

Bundle install vendor path vendor / bundle

Esto lo hizo por mí.

 0
Author: Bogdan Nechita,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-11-18 15:36:38

Necesitaba usar sudo

sudo gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config
 0
Author: gypsyDev,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-02-29 00:18:39

Funciona para mí

rvm list gemsets
rvm use ruby-2.4.1
bundle

error[![resuelto con rvm usar ruby]2

 -1
Author: DevMasterAryan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-01-27 23:13:03