开发者

Postgresql not working with ruby on rails on mac os x

I just switched to mac, I was previously working on Linux. I am trying to use posgresql for my project

When I start the server, it works fine.

Nevertheless when I use rake:db:migrate开发者_StackOverflow社区, it fails saying: Please install the postgresql adapter: gem install activerecord-postgresql-adapter (no such file to load -- pg)

I have the gem "pg" installed, and there are no such gem as activerecord-postgresql-adapter.

I find it weird that when I do ./script/server it works, but not when I do rake:db:migrate

Thnaks


Check to make sure that you've consistently installed your gems as root. If you have pg installed into ~/.gems/ruby/1.8/gems (or similar), you may encounter this (or a similar) issue.

(Additional information for Andrew's answer, pretty much.)


pg is the activerecord-postgresql-adapter gem, so that is what it is failing to find.

Since it is only failing from migrate, it might be rake is starting from a different version of ruby than console or script - do you have multiple versions of ruby?

Also since it is failing in rake, I would get the verbose (-v) output so you can see the stack trace, and see better what is going on, and at what point it tries to get pg but does not have the gem available. I have seen some weirdness with rake loading in a different order from rails start up, so that is not impossible.

There is a recent plugin that professes to help with pg migrations in rails, might help: http://github.com/alex3t/rails_on_pg

In case my guess above is completely unhelpful, here are some other places to look:

Project page for pg: https://rubyforge.org/projects/ruby-pg/

For more postgres on rails support: http://wiki.rubyonrails.org/database-support/postgres

Robby Russell write more about postgres than any other rails blogger I read: http://www.robbyonrails.com/articles/tag/postgresql


You may need to install one or more of the following

  • pkg postgresql
  • pkg postgresql-devel
  • gem pg


I just ran into this on Linux. In my case, the permissions were wrong: /usr/lib/ruby/gems/1.8/gems/pg-0.9.0 was set to 700.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜