0

I am trying to migrate from Heroku to AWS

I have created a stack with the following custom JSON:

{
  "deploy": {
    "appname": {
      "database": {
        "username": "myuser",
        "password": "password",
        "database": "databasename",
        "host": "rdsendpoint",
        "port": "5432",
        "adapter": "postgresql"
      }
    }
  }
}

I have created a RDS postgres DB and a Rails App Server. I have created an instance and an App linked to my git repository.

However the instance fails to start and I get this error message:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.


/usr/local/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
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/

extconf failed, exit code 1

Gem files will remain installed in /home/deploy/.bundler/authorship/ruby/2.0.0/gems/pg-0.18.2 for inspection.
Results logged to /home/deploy/.bundler/authorship/ruby/2.0.0/extensions/x86_64-linux/2.0.0/pg-0.18.2/gem_make.out
An error occurred while installing pg (0.18.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.2'` succeeds before bundling.

How can I fix this on AWS, since I cannot access the instance through ssh as it fails to start.

I tried to add a postgres-devel package to the layer, but I got a different error, seems that the package is no longer available.

2
  • "since I cannot access the instance through ssh as it fails to start" Why? You have to fix that one first Commented Jul 18, 2015 at 16:17
  • Since the app had trouble deployind the instance failed to start. I deleted the app, started the instance and then created an app again which failed to deploy until I installed libp-dev as suggested in the accepted answer Commented Jul 19, 2015 at 20:23

1 Answer 1

3

Since the instance doesn't have this package libpq-dev do

sudo apt-get install libpq-dev

So that pg gem can be installed.

Here's the description of libpq-dev:

Header files and static library for compiling C programs to link with the libpq library in order to communicate with a PostgreSQL database backend.

The pg gem is a native extension that wraps the libpq library.

P.S I recently ran into this problem, I got some explanation on other group.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.