no se puede instalar pg gem


Intenté usar gem install pg pero no parece funcionar.

gem install pg da este error

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

C:/Ruby/bin/ruby.exe 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=C:/Ruby/bin/ruby
        --with-pg
        --without-pg
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/lib
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config


Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/pg-0.10.1 for
inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/pg-0.10.1/ext/gem_make.out
Author: Matt, 2011-01-28

20 answers

Respondió aquí: No se puede instalar gema pg en Windows

No hay una versión nativa de Windows de lanzamiento de la última versión de pg (0.10.0) ayer, pero si se instala 0.9.0 debe instalar binarios sin cuestión.

 11
Author: Nikita Barsukov,
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:34:45

Tuve este problema, esto funcionó para mí:

Instale el paquete postgresql-devel, esto resolverá el problema de falta pg_config.

sudo apt-get install libpq-dev
 346
Author: Devaroop,
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-03-20 06:57:30

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

 57
Author: Flaviu,
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
2012-02-10 23:21:18

El problema es la dependencia de la gema, así que antes de instalar pg, asegúrese de haber instalado "libpq-dev"

Sistemas Ubuntu:

Sudo apt-get install libpq-dev

RHEL systems:

Yum install postgresql-devel

Mac:

Instalación de Brew postgresql

 53
Author: Mahattam,
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-02-24 09:37:28

@Winfield lo dijo :

La gema pg requiere que el cliente postgresql bibliotecas se vincule. Este error generalmente significa que no puede encontrar sus bibliotecas Postgres. O bien no los tiene instalados o puede que tenga que pasar el --with-pg-dir= a su instalación de gema.

Más que eso, solo necesita --with-pg-config= para instalarlo.

En un Mac

Si, por casualidad, también instaló postgres a través del paquete de sitios web en mac, estará en en algún lugar como /Applications/Postgres.app/Contents/Versions/9.3/bin.

Entonces, o bien lo pasas a la gema install:

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

O establece la RUTA correctamente. Dado que eso podría ser demasiado, para establecer temporalmente la RUTA:

export PATH=%PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin/
 33
Author: cregox,
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:34:45

No tenía instalado postgresql, así que lo instalé usando

sudo apt-get install postgresql postgresql-server-dev-9.1

En Ubuntu 12.04.

Esto lo resolvió.


Actualización:

Utilice la última versión:

sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3
 23
Author: Lasse Skindstad Ebert,
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-04-18 11:13:33

Trabajo en mi caso, yo uso ubuntu 14.04.2 LTS

Sudo apt-get install libpq-dev

Y yo uso

Ruby 2.2.2 & Carriles 4.2.1

 15
Author: Zainal,
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-06-16 13:53:46

Si está utilizando Postgres.app en Mac, puede resolver este problema de una vez por todas de la siguiente manera:

Primero gem uninstall pg, luego edita tu archivo ~/.bash_profile o ~/.zshrc o equivalente y agrega:

# PostgreSQL bin path
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin

Entonces bundle install y gem install pg ambos deberían funcionar como se esperaba.

 10
Author: Darme,
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-04 10:11:38
$ PATH=$PATH:/Library/PostgreSQL/9.1/bin sudo gem install pg

Reemplace la versión 9.1 para la versión instalada en su sistema.

 9
Author: jstnno,
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-02-07 21:33:16

En Mac OS (El Capitano). Simplemente puede usar: brew install postgresql

 5
Author: Jones Agyemang,
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-01-07 16:50:14

Utilizar con la bandera ARCH.

sudo env ARCHFLAGS="-arch x86_64" gem install pg

Esto resolvió el mismo problema que usted está teniendo.

 3
Author: Aman Chhabra,
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-10-22 10:02:17

La gema pg requiere que las bibliotecas cliente postgresql se vinculen. Este error generalmente significa que no puede encontrar sus bibliotecas Postgres. O bien no los tiene instalados o puede que necesite pasar --with-pg-dir = a su instalación de gema.

 2
Author: Winfield,
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
2011-01-28 18:14:10

Tuve este problema en Linux Mint (Maya) 13, Y lo arreglé instalando postgresql y postgresql-server:

apt-get install postgresql-9.1 

sudo apt-get install postgresql-server-dev-9.1
 2
Author: SAIDI Belkacem,
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-05-02 08:48:38

Para Usuarios de Mac

PATH=$PATH:/Library/PostgreSQL/9.4/bin/ gem install pg

Esto debería hacer el truco

 2
Author: Ronak Jain,
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-03-10 05:40:46

Tuve que hacer esto en CentOS 5.8. Ejecutar bundle install siguió causando problemas ya que no pude forzarlo a usar una versión PG en particular.

No puedo yum erase postgresql postgresql-devel tampoco, debido a problemas de dependencia (eliminaría php, http, etc.)

La solución? Mess temporarily RUTA temporal para dar preferencia a la actualización pgsql en lugar de la predeterminada:

export PATH=/usr/pgsql-9.2/bin:$PATH
bundle install

Básicamente, con los comandos anteriores, se verá en /usr/pgsql-9.2/bin/pg_config antes de la de /usr/bin/pg_config

 1
Author: Christian,
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
2012-10-18 07:17:28

Si está utilizando jruby en lugar de ruby, tendrá problemas similares al instalar la gema pg. En su lugar necesita instalar el adaptador:

gem 'activerecord-jdbcpostgresql-adapter'
 1
Author: Nuri,
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-06-16 19:49:44

En Mac brew install postgres LUEGO bundle install

 1
Author: Yar HTUT,
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-06-07 20:59:31

Independientemente del sistema operativo que esté ejecutando, mire el archivo de registros de "Makefile" para ver lo que está sucediendo, en lugar de instalar cosas a ciegas.

En mi caso, MAC OS, el archivo de registro está aquí:

/Users/za/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-1.0.0/mkmf.log

Los registros indicaban que el archivo make no se podía crear debido a lo siguiente:

Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers

Dentro del mkmf.registro, verá que no pudo encontrar las bibliotecas necesarias, para terminar la compilación.

checking for pg_config... no
Can't find the 'libpq-fe.h header
blah blah

Después de ejecutar "brew install postgresql", puedo ver que todas las bibliotecas requeridas son hay:

za:myapp za$ cat /Users/za/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-1.0.0/mkmf.log | grep yes
find_executable: checking for pg_config... -------------------- yes
find_header: checking for libpq-fe.h... -------------------- yes
find_header: checking for libpq/libpq-fs.h... -------------------- yes
find_header: checking for pg_config_manual.h... -------------------- yes
have_library: checking for PQconnectdb() in -lpq... -------------------- yes
have_func: checking for PQsetSingleRowMode()... -------------------- yes
have_func: checking for PQconninfo()... -------------------- yes
have_func: checking for PQsslAttribute()... -------------------- yes
have_func: checking for PQencryptPasswordConn()... -------------------- yes
have_const: checking for PG_DIAG_TABLE_NAME in libpq-fe.h... -------------------- yes
have_header: checking for unistd.h... -------------------- yes
have_header: checking for inttypes.h... -------------------- yes
checking for C99 variable length arrays... -------------------- yes
 1
Author: zee,
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-15 20:46:33

Simplemente vaya a aquí para ver si su versión pg admite la plataforma Win32, luego use este comando para instalar:

Gem install pg-v 0.14.1 platform platform = x86-mingw32

 0
Author: revskill,
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-01-04 06:29:21

He estado experimentando este molesto problema con PG durante años. Creé esta esencia para ayudar.

El siguiente comando siempre funciona para mí.

# Substitute Postgres.app/Contents/Versions/9.5 with appropriate version number
sudo ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config

Síntesis: https://gist.github.com/sharnie/5588340cf023fb177c8d

 0
Author: SharnieIvery,
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-03-21 14:34:17