Skip to content

Instantly share code, notes, and snippets.

@tomholford
Last active September 7, 2025 13:07
Show Gist options
  • Save tomholford/f38b85e2f06b3ddb9b4593e841c77c9e to your computer and use it in GitHub Desktop.
Save tomholford/f38b85e2f06b3ddb9b4593e841c77c9e to your computer and use it in GitHub Desktop.

Revisions

  1. tomholford revised this gist Jan 25, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_pg_gem.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ checking for libpq-fe.h... no
    Can't find the 'libpq-fe.h header
    ```

    The following helped me resolve the issue without having to install the entire postgresql as recommended in the stop Stack Overflow post (already using it in a Docker container):
    The following helped me resolve the issue without having to install the entire postgresql as recommended in [the stop Stack Overflow post](https://stackoverflow.com/a/6040822) (already using it in a Docker container):

    1. `brew install libpq`
    2. `gem install pg -- --with-pg-config=/usr/local/opt/libpq/bin/pg_config`
  2. tomholford renamed this gist Jan 25, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. tomholford created this gist Jan 25, 2021.
    22 changes: 22 additions & 0 deletions gistfile0.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # Installing `pg` gem on macOS

    If you're trying to install the postgresql gem `pg` and it is failing with the following error message:

    ```
    Installing pg 1.2.3 with native extensions
    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: ~/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/pg-1.2.3/ext
    ~/.rbenv/versions/3.0.0/bin/ruby -I ~/.rbenv/versions/3.0.0/lib/ruby/3.0.0 -r ./siteconf20210125-97201-pycpo.rb 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
    ```

    The following helped me resolve the issue without having to install the entire postgresql as recommended in the stop Stack Overflow post (already using it in a Docker container):

    1. `brew install libpq`
    2. `gem install pg -- --with-pg-config=/usr/local/opt/libpq/bin/pg_config`