1

I'm developing a rails app using sqlite3. I want to push it to Heroku. In Heroku tutorial it says that I have to first change:

gem 'sqlite3'

to

gem 'pg'

and run

bundle install

I got this error:

 Installing pg (0.14.1) with native extensions 
 Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
 ...
 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.
 ...

next I tried the solution proposed here:

 running gem install pg -- --with-pg-config= /usr/bin/pg_config

I also tried running:

 sudo apt-get install postgresql
 sudo apt-get install libpq-dev

and

 gem install pg

works fine..

But

 bundle install

still gives me the same error

Note: I'm using rvm

Community
  • 1
  • 1
shane
  • 2,071
  • 3
  • 15
  • 16
  • I think the fact that I'm using rvm is somehow making things complicated so none of the solutions on SO works... – shane Dec 07 '12 at 21:06

2 Answers2

1

did you try

group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end

in your gemfile so that you can use sqlite in development and when you push to heroku as production it will be pg.

shane
  • 2,071
  • 3
  • 15
  • 16
Richard Lau
  • 696
  • 9
  • 22
  • yes tried this. and then 'bundle install'.. still getting the same error – shane Dec 07 '12 at 20:55
  • 1
    @shane: Did you specify a `--without` option? E.g., `bundle install --without=production`? – mipadi Dec 07 '12 at 21:11
  • I did. This way the 'bundle install' goes well but then when I want to push it to heroku... I still get: updated Gemfile.lock to version control. You have added to the Gemfile: * pg You have deleted from the Gemfile: * sqlite3 – shane Dec 07 '12 at 21:46
0

Change your gemfile to the following:

gem 'sqlite3', :group => :development
gem 'pg', :group => :production

This way you will use SQL locally in development. Heroku will ignore the sqlite gem, and use Postgres instead.

Shaun
  • 583
  • 5
  • 19
  • This is a way to do it. But it doesn't address the problem of not being able to install postgresql locally. The user should be able to so that if they wish. – dcow Dec 07 '12 at 20:16
  • You are correct, but I don't think that is his request. "I'm developing a rails app using sqlite3. I want to push it to Heroku." It is common practice to develop with sql and push to heroku with pg. Heroku's instructions to move to dev work to postgres can be ignored. – Shaun Dec 07 '12 at 21:12
  • sure, I just want to make sure the OP knows the difference (= – dcow Dec 07 '12 at 21:15