Rails 3.1 - 推送到 Heroku - 安装 postgres 适配器时出错?

发布于 2024-12-02 23:52:40 字数 1591 浏览 1 评论 0原文

我刚刚升级到 Rails 3.1,我尝试部署到 Heroku 的第一个应用程序遇到了与 Postgres 适配器相关的问题。我可以将应用程序推送到heroku,但是当我尝试迁移数据库时,出现以下错误:

heroku rake db:migrate

rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` 
(pg is not part of the bundle. Add it to Gemfile.)
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)

当我尝试他们建议的安装时,我得到:

ERROR:  Could not find a valid gem 'activerecord-postgresql-adapter' (>= 0) in any repository
ERROR:  Possible alternatives: activerecord-postgis-adapter, activerecord-jdbcpostgresql-adapter, activerecord-postgresql-cursors, activerecord-jdbcmysql-adapter, activerecord-jdbcmssql-adapter

这看起来已经很奇怪了...所以到底是什么gem如果不是他们所说的我应该安装的东西,我应该安装以使这个东西正常工作吗?

当我尝试安装 gem pg 时,我得到:

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

/Users/jerometufte/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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.

Provided configuration options:
    --with-opt-dir
    ...

我当前正在使用 SQLite3。非常感谢任何帮助,这让我感到困惑。

I just upgraded to Rails 3.1 and the first app i've tried to deploy to Heroku has encountered a problem relating to Postgres adapter. I'm able to push the app to heroku but then when i try to migrate the database i get the following error:

heroku rake db:migrate

rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` 
(pg is not part of the bundle. Add it to Gemfile.)
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)

when I try their suggested install i get:

ERROR:  Could not find a valid gem 'activerecord-postgresql-adapter' (>= 0) in any repository
ERROR:  Possible alternatives: activerecord-postgis-adapter, activerecord-jdbcpostgresql-adapter, activerecord-postgresql-cursors, activerecord-jdbcmysql-adapter, activerecord-jdbcmssql-adapter

which already seems weird... so what exact gem should I install to get this thing working if not what they say I should install??

When I try installing gem pg i get:

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

/Users/jerometufte/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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.

Provided configuration options:
    --with-opt-dir
    ...

I'm using SQLite3 currently. Any help greatly appreciated, this is baffling me.

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

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

发布评论

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

评论(3

过期情话 2024-12-09 23:52:40

选项 1:

pg 添加到您的 Gemfile,但跳过尝试在本地安装它。

$ cat Gemfile
...
group :production do
  # gems specifically for Heroku go here
  gem "pg"
end

# Skip attempting to install the pg gem
$ bundle install --without production

选项 2 (Debian/Ubuntu):

pg 添加到您的 Gemfile,但首先安装先决条件。

$ cat Gemfile
...
group :production do
  # gems specifically for Heroku go here
  gem "pg"
end

# Install the pg gem's dependencies first
$ sudo apt-get install libpq-dev
# Then install the pg gem along with all the other gems
$ bundle install

Option 1:

Add pg to your Gemfile but skip trying to install it locally.

$ cat Gemfile
...
group :production do
  # gems specifically for Heroku go here
  gem "pg"
end

# Skip attempting to install the pg gem
$ bundle install --without production

Option 2 (Debian/Ubuntu):

Add pg to your Gemfile but first install the prerequisites.

$ cat Gemfile
...
group :production do
  # gems specifically for Heroku go here
  gem "pg"
end

# Install the pg gem's dependencies first
$ sudo apt-get install libpq-dev
# Then install the pg gem along with all the other gems
$ bundle install
故事未完 2024-12-09 23:52:40

您肯定需要 Heroku 的 Gemfile 中的 pg。

关于您在本地遇到的错误:确保安装了 postgres,运行 gem install pq -- --with-pg-config=[pg-config 二进制文件所在的路径],然后捆绑安装。

或者,如果您的本地数据库工作正常(因为您使用的是 sqlite 或 postgres-pr),您可以将 gem 'pg' 行放入 Gemfile 中名为 production 的组中,然后 <本地代码>捆绑安装--无需生产。

You definitely need pg in the Gemfile for Heroku.

About the error you're getting locally: make sure you have postgres installed, run gem install pq -- --with-pg-config=[path to wherever your pg-config binary is], then bundle install.

Alternatively, if your local database is working fine (either because you're using sqlite or postgres-pr), you could put the gem 'pg' line in your Gemfile in a group called production, then bundle install --without production locally.

固执像三岁 2024-12-09 23:52:40

更多最新信息:这与本地 pg gem 的不同版本有关。

我已经在生产组中加入了 pg(我在本地运行 sqllite),但 Heroku 仍然在呕吐。

我的新 Rails 3.1 应用程序的问题就消失了:

rm Gemfile.lock
touch Gemfile
bundle install
git add .
git commit -am "wiped Gemfile.lock re-ran bundle install"
git push heroku master

当我运行 heroku run rake db:migrate 时,

More up-to-date info: It had something to do with a different version of pg gem locally.

I already had pg in a production group (I run sqllite locally), but Heroku was still puking.

The problem went away for my new Rails 3.1 app when I:

rm Gemfile.lock
touch Gemfile
bundle install
git add .
git commit -am "wiped Gemfile.lock re-ran bundle install"
git push heroku master

worked like a charm when I then ran heroku run rake db:migrate

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