加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – Rails 3.1 – 推送到Heroku – 安装postgres适配

发布时间:2020-12-13 16:49:31 所属栏目:百科 来源:网络整理
导读:我刚刚升级到Rails 3.1和我尝试部署到Heroku的第一个应用程序遇到与Postgres适配器相关的问题。我可以推送应用程序到heroku,但当我尝试迁移数据库时,我得到以下错误: heroku rake db:migrate rake aborted!Please install the postgresql adapter: `gem
我刚刚升级到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。任何帮助非常感谢,这是令人不安的我。

选项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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读