rake aborted! no such file to load -- pg (Creating postgre database in rails ) rake aborted! no such file to load -- pg (Creating postgre database in rails ) postgresql postgresql

rake aborted! no such file to load -- pg (Creating postgre database in rails )


If you are using PostgreSQL 9 downloaded from enterprisedb you need to install the pg gem in one of the following way:

If you use rvm use:

env ARCHFLAGS="-arch x86_64" \  gem install pg -- \  --with-pg-include=/Library/PostgreSQL/9.0/include/ \  --with-pg-lib=/Library/PostgreSQL/9.0/lib/

Otherwise use:

sudo env ARCHFLAGS="-arch x86_64" \  gem install pg -- \  --with-pg-include=/Library/PostgreSQL/9.0/include/ \  --with-pg-lib=/Library/PostgreSQL/9.0/lib/

If that doesn't work, we need to know which version of OSX and which version of PostgreSQL.


make sure you have the pg gem installed.

gem install pg

or

include gem pg in your Gemfile and run bundle install if using bundler


All right. Another day, another opportunities.

I found the problem! If you want to install "gem install pg" you need to have the postgres header files on your machine. After I installed Postgres 8.3 via Macports I was also able to install the pg gem. I used this command to install the pg gem:

sudo env ARCHFLAGS='-arch i386' gem install pg

I found the solution in this blog post:

http://flux88.com/blog/installing-postgresql-for-rails-on-mac-os-x/

After reading the post and all the comments, I could resolve the problem.