Installing postgres gem when database is on a diff

2019-02-17 13:56发布

问题:

My database is on a different server to the application. When I run "bundle" I get the following error:

No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config

How do I set the pg config path if pg is not actually installed on the application server? I have also tried:

bundle config build.pg --without-pg_config

Thanks

回答1:

The Ruby PostgreSQL interface (AKA the pg gem) is just a thin wrapper around the PostgreSQL client C libraries. You need to install the PostgreSQL client libraries and headers or you can't install the pg gem. You don't need a whole PostgreSQL installation on your app server, just the client development libraries, the package is probably called something like "libpg-dev" or "libpq-dev".