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
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.