I'm trying to start a rails project with a postgresql database but when i try to create the db with the command:
rake db:create
I'm getting the following error message:
rake aborted! no such file to load -- pg
I'm using mac os X so postgresql is intalled in the /Library folder. I've look around for the pg file but i could not find it and i
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With