我正在使用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
我正在尝试为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) 每次我运行我的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) 当我尝试运行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) 我正在尝试安装pg gem以便在我的本地机器上使用Postgres.app.我正在经营小牛队.
Postgres.app安装并运行正常,但我无法让宝石工作.我做了以下事情:
一切都没有成功.这是我收到的具体错误消息:
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) 当我跑(以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) 我正在尝试创建一个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)
关于这个问题的任何想法的人.
$ 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) 每次运行我的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)

我试图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) pg ×10
postgresql ×6
ruby ×3
macos ×2
activerecord ×1
bundler ×1
libpq ×1
rollback ×1
rubygems ×1
sqlite ×1