耙子中止!没有要加载的文件 - pg(在 Rails 中创建 postgre 数据库)

发布于 2024-10-04 15:41:40 字数 218 浏览 0 评论 0 原文

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

rake db:create

我收到以下错误消息:

rake aborted! 没有这样的文件要加载 -- pg

我使用的是 mac os X,所以 postgresql 安装在 /Library 文件夹中。我四处寻找 pg 文件,但找不到它,我

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

终陌 2024-10-11 15:41:40

您使用的是从 enterprisedb 下载的 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/

否则使用:

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/

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

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.

内心激荡 2024-10-11 15:41:40

确保您已安装 pg gem。

gem install pg

在 Gemfile 中包含 gem pg 并运行 bundle install(如果使用捆绑器)

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

中二柚 2024-10-11 15:41:40

好的。另一天,另一次机会。

我发现问题了!如果你想安装“gem install pg”,你的机器上需要有 postgres 头文件。通过 Macports 安装 Postgres 8.3 后,我还可以安装 pg gem。我使用这个命令来安装 pg gem:

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

我在这篇博客文章中找到了解决方案:

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

阅读帖子和所有评论后,我可以解决问题。

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.

奈何桥上唱咆哮 2024-10-11 15:41:40

对我来说这是行不通的。

ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /opt/local/bin/ruby1.9 extconf.rb --with-pg-include=/Library/PostgreSQL/8.4/include/ --with-pg-lib=/Library/PostgreSQL/8.4/lib/ --with-pg-config=/Library/PostgreSQL/8.4/bin/pg_config
Using config values from /Library/PostgreSQL/8.4/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.

Ruby + PostgreSQL = 屁股上的痛苦!

我不奇怪为什么每个人都使用 mySQL 而不是 Postgres。使用 mySQL 我从未遇到过如此多的麻烦。它易于安装且易于使用。使用 Postgres 我总是遇到问题。

经过几个小时的故障排除和谷歌搜索糟糕的 postgres ruby​​ 驱动程序后,我非常生气。明天我会看看 MongoDB,我希望它比 Postgres 少一些痛苦!

晚安!

For me it does not work.

ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /opt/local/bin/ruby1.9 extconf.rb --with-pg-include=/Library/PostgreSQL/8.4/include/ --with-pg-lib=/Library/PostgreSQL/8.4/lib/ --with-pg-config=/Library/PostgreSQL/8.4/bin/pg_config
Using config values from /Library/PostgreSQL/8.4/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.

Ruby + PostgreSQL = Pain in the ASS!

I not wondering why everybody uses mySQL instead of Postgres. With mySQL I never had so much trouble. It is easy to install and easy to use. With Postgres I have always just problems.

After hours of troubleshooting and googeling for shitty postgres ruby driver I am very pissed off. Tomorrow I will take a look to MongoDB and I hope it is less pain than Postgres!

good night!

东北女汉子 2024-10-11 15:41:40

问题是你没有正确安装 PostgreSQL。

用户 Brew 安装 PostgreSQL。

brew update

然后安装 PostgreSQL。

brew install postgresql

确保您遵循 PostgreSQL 的说明,并且您安装的版本与您正在使用的版本匹配。

你可以通过这样做来获取版本。

psql --version

PostgreSQL值得学习,而且比MYSQL先进很多。正确使用它将改进您的 Rails 应用程序。

本教程帮助我学习。

问题是你没有正确安装 PostgreSQL。

用户 Brew 安装 PostgreSQL。

brew update

然后安装 PostgreSQL。

brew install postgresql

确保您遵循 PostgreSQL 的说明,并且您安装的版本与您正在使用的版本匹配。

你可以通过这样做来获取版本。

psql --version

PostgreSQL值得学习,而且比MYSQL先进很多。正确使用它将改进您的 Rails 应用程序。

本教程帮助我学习。

http://railscasts.com/episodes/342-migration-to-postgresql

The problem is you didn't install PostgreSQL properly.

User Brew to install PostgreSQL.

brew update

then install PostgreSQL.

brew install postgresql

Make sure you follow the instructions for PostgreSQL and that the version you installed matches the version you are using.

you can get the version by doing.

psql --version

PostgreSQL is worth learning and much more advanced than MYSQL. Used properly it will improve your Rails application.

This tutorial helped me learn.

The problem is you didn't install PostgreSQL properly.

User Brew to install PostgreSQL.

brew update

then install PostgreSQL.

brew install postgresql

Make sure you follow the instructions for PostgreSQL and that the version you installed matches the version you are using.

you can get the version by doing.

psql --version

PostgreSQL is worth learning and much more advanced than MYSQL. Used properly it will improve your Rails application.

This tutorial helped me learn.

http://railscasts.com/episodes/342-migrating-to-postgresql

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文