Rails 3.1 - 推向Heroku - 错误安装postgres适配器? [英] Rails 3.1 - Pushing to Heroku - Errors installing postgres adapter?
问题描述
我刚刚升级到Rails 3.1,我尝试部署到Heroku的第一个应用程序遇到了与Postgres适配器相关的问题。我能够将应用程序推送到heroku,但是当我尝试迁移数据库时,出现以下错误:
heroku rake db:migrate
rake中止!
请安装postgresql适配器:`gem install activerecord-postgresql-adapter`
(pg不是该软件包的一部分,将它添加到Gemfile中)
任务:TOP => db:migrate => db:load_config
(通过使用--trace运行任务来查看完整跟踪)
尝试他们的建议安装我得到:
错误:无法找到有效的gem'activerecord-postgresql-adapter'(> 0)在任何存储库中
错误:可能的替代方案:activerecord-postgis-adapter,activerecord-jdbcpostgresql-adapter,activerecord-postgresql-cursors,activerecord-jdbcmysql-adapter,activerecord-jdbcmssql-adapter
这已经显得不可思议了......那么我应该安装什么样的gem来让这个东西工作,如果不是他们说我应该安装的? ?
当我尝试安装gem pg时,我得到:
扩展。这可能需要一段时间...
错误:安装pg时出错:
错误:无法构建gem本机扩展。
/Users/jerometufte/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
检查pg_config ... no
没有pg_config。无论如何,尝试。如果构建失败,请再次尝试使用
--with-pg-config = / path / to / pg_config
检查libpq-fe.h ... no
无法找到'libpq-fe.h头文件
*** extconf.rb失败***
由于某种原因无法创建Makefile,可能缺少
必需的库和/或头文件。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。
提供的配置选项:
--with-opt-dir
...
目前我正在使用SQLite3。任何帮助非常感谢,这让我感到莫名其妙。
选项1:
在您的 Gemfile
中添加 pg
,但不要尝试在本地安装。
$ cat Gemfile
...
组:生产do
#专为Heroku设计的宝石go here
宝石pg
end
#跳过试图安装pg gem
$ bundle install --without production
$ b $选项2(Debian / Ubuntu):添加 pg
到您的 Gemfile
,但首先安装必备软件。
$ cat Gemfile
...
组:生产do
#专门用于Heroku的宝石去这里
gempg
结束
#安装pg gem的依赖首先是
$ sudo apt-get install libpq-dev
然后安装pg gem以及所有其他gem
$ bundle install
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.
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
这篇关于Rails 3.1 - 推向Heroku - 错误安装postgres适配器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!