Rails 3.1 - Pushing to Heroku - Errors installing postgres adapter?

时间秒杀一切 提交于 2019-11-29 19:44:05

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

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!