Ruby application: bundle install error due to can't find postgresql client library?

Viewed 42

Hello I'm very new with Ruby but I've been tasked to start a deprecated ruby application

I installed the dependencies

- Ruby version
  `rbenv install 2.3.1`
  `gem install bundle`
  `bundle install`

- System dependencies
  `brew install postgresql@9.6`
  `brew services start postgresql@9.6`
  `brew link postgresql@9.6 --force`

Since 9.6 is disabled I'm using 9.5 for postgresql

When I run sudo bundle install (since permisson error)

I run into this error

checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***

I have libpq and postgresql installed by brew..

What am I missing?

1 Answers

Before getting to an answer, it's SUPER important to never run sudo with bundle. This will install the gems with sudo power, meaning they can affect your machine with sudo power. Definitely a very bad thing to give other people's code full sudo access to your machine.

Next, you need to install [libpq-dev][1] before running bundle. This installs necessary binaries and headers needed to create postgresql apps.

On Linux (Ubuntu) run the following:

sudo apt-get install libpq-dev

If you're on Mac you just need to run:

brew install postgresql

and that will install the needed headers for you automatically. [1]: https://pypi.org/project/libpq-dev/

Related