5

Here's my problem. I am trying to create a blog. I run 'rails new blog'. Everythign is OK until I try 'rake db:create'. It returns an error:

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

When I try to install pg adapter I get this:

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

need configuration options.

My 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'

Got any idea?

3
  • try to run bundle install --path vendor/gems Some time ago, that helped me Commented Mar 11, 2013 at 13:19
  • Have you installed devkit? Commented Mar 14, 2013 at 3:35
  • You can look at this post : stackoverflow.com/questions/7086654/… Commented Mar 15, 2013 at 10:25

4 Answers 4

3
+25

Do you have Postgres installed? If so, make sure that pg_config.exe is in the PATH. Alternatively use either --with-pg-config or –with-pg-dir key:

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

See details in https://github.com/ged/ruby-pg/blob/master/README-Windows.rdoc

Sign up to request clarification or add additional context in comments.

Comments

2

Uninstall pg gem, and install postgres-pr for windows

Remove from Gemfile:

gem "pg"

and put:

gem "postgres-pr"

and run:

bundle install or gem install postgres-pr or however you are installing gems

Comments

1

You are missing the library for postgresql. You can install it like this:

sudo apt-get install libpq-dev

Maybe also take a look at this old question.

2 Comments

Problem is that I work on windows (yeah, I know it's wrong but I am only begginer) so sudo is not working here
Then maybe take a look at this one: stackoverflow.com/questions/7086654/…
0

I got the same error and I solved by setting correct file permissions to postgresql_adapter.rb

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

Somehow the file permissions of postgresql_adapter.rb were corrupted in my computer...

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.