Or little computing tricks and hacks
psql as a gem
August 30, 2013Posted by on
The initial Rails infrastructure uses sqlite3 as the default database. Heroku, on the other hand, uses postgresql. Given that Heroku advices the use of the same database for development as for deployment, in the sample app of the tutorial it is advised to upgrade to psql.
gem install pg -v '0.15.1', I got a nasty error:
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
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.
After come searching, I found that in Ubuntu, I need to install an extra package:
sudo apt-get install libpq-dev
And presto. After installation, the gem is happily installed:
$ gem install pg -v ‘0.15.1’
Building native extensions. This could take a while…
Successfully installed pg-0.15.1
1 gem installed
The trick was found in this site. There are some header files missing, needed by gem install, available after libpq-dev is installed.