2013-03-11 44 views
4

這是我的問題。我正在嘗試創建一個博客。我運行'rails新博客'。 Everythign是好的,直到我嘗試'rake db:create'。它返回一個錯誤:在rails中的活動記錄postgresql適配器錯誤

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' 

有任何想法?

+0

嘗試運行'捆綁安裝--path供應商/前gems'一些時間,幫助我 – 2013-03-11 13:19:23

+0

你有沒有安裝'的devkit '? – 2013-03-14 03:35:56

+0

你可以看看這篇文章:http://stackoverflow.com/questions/7086654/installing-postgres-on-windows-for-use-with-ruby-on-rails – rbinsztock 2013-03-15 10:25:14

回答

1

您缺少postgresql的庫。 你可以像這樣安裝:

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

也許還看一看this old question

+0

問題是,我工作的窗口(是的,我知道這是錯誤的,但我只是begginer)所以sudo不在這裏工作 – szatan 2013-03-13 14:38:28

+0

然後,也許看看這個:http://stackoverflow.com/questions/7086654/installing-postgres-on-windows-for-use-與-的Ruby-on-軌道 – 2013-03-13 14:45:24

2

卸載pg寶石的詳細信息,以及Windows

安裝postgres-pr從Gemfile中刪除:

gem "pg" 

,並把:

gem "postgres-pr" 

並運行:

bundle installgem install postgres-pr但是還是要安裝寶石