在轨活动记录PostgreSQL的适配器错误

问题描述 投票:5回答:4

这里是我的问题。我想创建一个博客。我运行“轨道的新博客”。 Everythign是OK,直到我尝试“耙分贝:创建”。它返回一个错误:

rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adap
ter` (pg is not part of the bundle. Add it to Gemfile.)

当我尝试安装PG适配器我得到这样的:

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

F:/Ruby200-x64/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

需要配置选项。

我的Gemfile:

  source 'https://rubygems.org'

gem 'rails', '3.2.12'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem "pg"

# Gems used only for assets and not required
# in production environments by default.
 group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

有什么想法?

ruby-on-rails ruby-on-rails-3.1 gem
4个回答
3
投票

你有安装Postgres的?如果是这样,请确保pg_config.exe是在PATH中。或者请使用--with-pg-config–with-pg-dir键:

gem install pg --with-pg-config=<path>

https://github.com/ged/ruby-pg/blob/master/README-Windows.rdoc细节


2
投票

卸载pg宝石,和Windows安装postgres-pr

从的Gemfile删除:

gem "pg"

并提出:

gem "postgres-pr"

然后运行:

bundle installgem install postgres-pr或不过你要安装的宝石


1
投票

你缺少对PostgreSQL库。你可以像这样安装:

命令和apt-get安装的libpq-dev的

也许还看一看this old question


0
投票

我得到了同样的错误,我解决了通过设置正确的文件权限postgresql_adapter.rb

cd [YOUR_ACTIVERECORD_GEM_PATH]/lib/active_record/connection_adapters
chmod 644 postgresql_adapter.rb

不知怎的,postgresql_adapter.rb的文件权限在我的电脑被损坏...

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.