标签: pg

在尝试安装pg gem时找不到'libpq-fe.h标头

我正在使用Ruby on Rails 3.1预发行版.我喜欢使用PostgreSQL,但问题是安装pggem.它给了我以下错误:

$ gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /home/u/.rvm/rubies/ruby-1.9.2-p0/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 …
Run Code Online (Sandbox Code Playgroud)

postgresql ruby-on-rails pg ruby-on-rails-3 rails-postgresql

753
推荐指数
25
解决办法
27万
查看次数

如何在Ubuntu上安装PostgreSQL的pg gem?

我正在尝试为Ruby安装PostgreSQL的pg gem.

我发出了以下命令:

gem install pg
Run Code Online (Sandbox Code Playgroud)

我使用RVM安装了Ruby 1.9.2.

上面的命令显示以下错误.

错误是:

Building native extensions.  This could take a while...

ERROR:  Error installing pg:

ERROR: Failed to build gem native extension.

/home/User/.rvm/rubies/ruby-1.9.2-preview3/bin/ruby extconf.rb

checking for pg_config... yes
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)

*** extconf.rb failed ***

Could not create Makefile due to some reason, …
Run Code Online (Sandbox Code Playgroud)

ruby postgresql pg

280
推荐指数
12
解决办法
12万
查看次数

PG :: ConnectionBad - 无法连接到服务器:连接被拒绝

每次我运行我的rails 4.0服务器,我得到这个输出.

Started GET "/" for 127.0.0.1 at 2013-11-06 23:56:36 -0500

PG::ConnectionBad - could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 5432?
: …
Run Code Online (Sandbox Code Playgroud)

ruby database-connection ruby-on-rails pg rails-postgresql

253
推荐指数
15
解决办法
22万
查看次数

Rails 3 - 无法安装pg gem

当我尝试运行bundle(bundle install)时,我总是得到

Installing pg (0.13.2) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/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 …
Run Code Online (Sandbox Code Playgroud)

macos ruby-on-rails libpq pg postgresql-9.1

96
推荐指数
7
解决办法
8万
查看次数

使用Postgres.app无法在Mavericks中安装pg gem

我正在尝试安装pg gem以便在我的本地机器上使用Postgres.app.我正在经营小牛队.

Postgres.app安装并运行正常,但我无法让宝石工作.我做了以下事情:

  1. 使用Postgres.app文档中的命令'env ARCHFLAGS =" - arch x86_64"gem install pg - --with-pg-config =/Applications/Postgres.app/Contents/MacOS/bin/pg_config'
  2. 更新了Homebrew并安装了Apple GCC 4.2
  3. 安装了Xcode开发人员工具
  4. 更新了我的$ PATH以引用Postgres.app bin和lib目录

一切都没有成功.这是我收到的具体错误消息:

Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config'
This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /Users/Brian/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/MacOS/bin/pg_config
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not …
Run Code Online (Sandbox Code Playgroud)

postgresql macos ruby-on-rails pg osx-mavericks

71
推荐指数
4
解决办法
3万
查看次数

gem install pg --with-pg-config工作,bundle失败

当我跑(以root身份)

gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

#-> gem instal pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Building native extensions.  This could take a while...
Successfully installed pg-0.12.0
1 gem installed
Installing ri documentation for pg-0.12.0...
Installing RDoc documentation for pg-0.12.0...
#-> 
Run Code Online (Sandbox Code Playgroud)

当我运行bundle install时:

Installing pg (0.12.0) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-1.9.2-p290/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 …
Run Code Online (Sandbox Code Playgroud)

postgresql rubygems bundler pg

69
推荐指数
7
解决办法
7万
查看次数

ActiveRecord :: StatementInvalid:PG InFailedSqlTransaction

我正在尝试创建一个ActiveRecord Object.But我在创建它时遇到此错误.

(0.1ms)  ROLLBACK
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is       aborted, commands ignored until end of transaction block
Run Code Online (Sandbox Code Playgroud)

关于这个问题的任何想法的人.

postgresql activerecord ruby-on-rails rollback pg

66
推荐指数
5
解决办法
3万
查看次数

rails install pg - 找不到'libpq-fe.h标头

$ sudo bundle install
Run Code Online (Sandbox Code Playgroud)

结果

Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Using rake (0.9.2.2) 
Using i18n (0.6.1) 
Using multi_json (1.3.6) 
Using activesupport (3.2.8) 
Using builder (3.0.4) 
Using activemodel (3.2.8) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.3) 
Using actionpack (3.2.8) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.11) 
Using mail (2.4.4) 
Using actionmailer (3.2.8) 
Using arel (3.0.2) 
Using tzinfo …
Run Code Online (Sandbox Code Playgroud)

sqlite ruby-on-rails pg ruby-on-rails-3

65
推荐指数
8
解决办法
5万
查看次数

Postgresql适配器(pg):无法连接到服务器

每次运行我的Rails应用程序时都会收到此错误(它无法连接到我的本地Postgresql)

/Users/leonardo/.rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.11/lib/
active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize': 
could not connect to server: No such file or directory (PG::Error)
   Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)

我正在使用Postgres.app,它正确运行.

如果我跑

$ psql
Run Code Online (Sandbox Code Playgroud)

我可以正确登录到Postgresql控制台.

$ which psql
 /Applications/Postgres.app/Contents/MacOS/bin/psql
Run Code Online (Sandbox Code Playgroud)

的Gemfile

source 'https://rubygems.org'
ruby "1.9.3"

gem 'rails', '3.2.11'
gem "pg"
Run Code Online (Sandbox Code Playgroud)

database.yml的

development:
  adapter: postgresql
  encoding: unicode
  username: leonardo
  password: 
  database: zapping
  port: 5432  
Run Code Online (Sandbox Code Playgroud)

Postgresql(控制台)

$ psql
leonardo=# \l
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

postgresql ruby-on-rails pg rails-postgresql

65
推荐指数
9
解决办法
7万
查看次数

错误:无法在Mavericks上构建gem原生扩展

我试图bundle在OSX 10.9上运行我的Rails项目.pg使用此错误进入gem 时失败:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/kyledecot/.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... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQescapeLiteral()... yes
checking …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails pg ruby-on-rails-4 osx-mavericks

46
推荐指数
5
解决办法
5万
查看次数