1

got an issue when trying to bundle a rails project that need the pg gem. I actually try a lot of solution ARM based with no actual result.

When bundle I get this error :

An error occurred while installing pg (1.2.3), and Bundler cannot continue.
Make sure that `gem install pg -v '1.2.3' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  active_storage-postgresql was resolved to 0.2.1, which depends on
    pg

And when I run the command I get this :

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=/Users/maximjoseau/.rbenv/versions/2.7.1/bin/$(RUBY_BASE_NAME)
    --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}/lib


extconf failed, exit code 1

Any idea how to fix this ? I cant quite find a viable solution

max.jos
  • 11
  • 1
  • 4
  • Same problem as https://stackoverflow.com/q/6040583/479863 but different OS? i.e. you don't have PostgreSQL's development libraries installed. – mu is too short Nov 23 '21 at 18:52
  • Unfortunately I already tried it with no good result. Still, I somehow manage to make it work by installing Postgres.app – max.jos Nov 25 '21 at 08:46
  • Please edit your question to include info found in the `mkmf.log` file. The error message indicates you might find some useful info in that file. – leifericf Nov 27 '21 at 15:23
  • 1
    This is almost certainly some part of the process expecting a ```/usr/local``` prefix for homebrew, when in reality it's now /opt/homebrew. As a test, try a ```ln -s /opt/homebrew /usr/local``` (as long as there's nothing at /usr/local) – Matthias Winkelmann Nov 29 '21 at 15:05
  • I've been using Rails and Postgres successfully on M1 MacBook for over a year without issues. Then after updating pg gem to version 1.3.5 from version 1.1.4, I stared getting this error. Not not sure how to resolve it. – user24601 Feb 08 '23 at 16:16

0 Answers0