耙子流产了!没有这样的文件加载 - pg(在rails中创建postgre数据库)

Fgb*_*nch 7 postgresql macos rake ruby-on-rails

我正在尝试使用postgresql数据库启动rails项目但是当我尝试使用以下命令创建db时:

rake db:create

我收到以下错误消息:

耙子流产了!没有这样的文件加载 - pg

我正在使用mac os X,因此postgresql被安装在/ Library文件夹中.我四处寻找pg文件,但我找不到它,我

Sin*_*ris 8

如果您使用从enterpriseedb下载的PostgreSQL 9,则需要以下列方式之一安装pg gem:

如果你使用rvm使用:

env ARCHFLAGS="-arch x86_64" \
  gem install pg -- \
  --with-pg-include=/Library/PostgreSQL/9.0/include/ \
  --with-pg-lib=/Library/PostgreSQL/9.0/lib/
Run Code Online (Sandbox Code Playgroud)

否则使用:

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/
Run Code Online (Sandbox Code Playgroud)

如果这不起作用,我们需要知道哪个版本的OSX和哪个版本的PostgreSQL.


Doo*_*oon 7

确保你安装了pg gem.

gem install pg

要么

包含gem pg在您的Gemfile中并bundle install 在使用bundler时运行