简体   繁体   中英

Error extconf.rb:42:in `popen': No such file or directory - /usr/pgsql-9.1/bin/pg_config (Errno::ENOENT) from extconf.rb:42:in `<main>'

Trying to use standup a Rails project I've used before, but I'm getting errors during bundle install. The postgres version I have installed is 9.6. Ruby is 2.7.1. Worked before up to this point by now I can't get a bundle install or bundle update to run.

$ bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies......
Using rake 12.3.3
Using concurrent-ruby 1.1.10
Using i18n 1.10.0
Using minitest 5.15.0
Using thread_safe 0.3.6
Using tzinfo 1.2.9
Using zeitwerk 2.5.4
Using activesupport 6.0.5
Using builder 3.2.4
Using erubi 1.10.0
Using mini_portile2 2.8.0
Using racc 1.6.0
Using nokogiri 1.13.6 (x86_64-darwin)
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.18.0
Using rails-html-sanitizer 1.4.2
Using actionview 6.0.5
Using rack 2.2.3
Using rack-test 1.1.0
Using actionpack 6.0.5
Using nio4r 2.5.8
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.5
Using actioncable 6.0.5
Using globalid 1.0.0
Using activejob 6.0.5
Using activemodel 6.0.5
Using activerecord 6.0.5
Using marcel 1.0.2
Using activestorage 6.0.5
Using mini_mime 1.1.2
Using mail 2.7.1
Using actionmailbox 6.0.5
Using actionmailer 6.0.5
Using actiontext 6.0.5
Using annotate 2.7.5
Using ast 2.4.2
Using aws-eventstream 1.2.0
Using aws-partitions 1.587.0
Using aws-sigv4 1.5.0
Using jmespath 1.6.1
Using aws-sdk-core 3.131.0
Using aws-sdk-kms 1.56.0
Using aws-sdk-s3 1.114.0
Using bindex 0.8.1
Using msgpack 1.5.1
Using bootsnap 1.11.1
Using method_source 1.0.0
Using thor 1.2.1
Using railties 6.0.5
Using bootstrap-form 4.0.0
Using bundler 2.1.4
Using byebug 11.1.3
Using childprocess 4.1.0
Using coderay 1.1.3
Using docile 1.4.0
Using dotenv 2.7.6
Using dotenv-rails 2.7.6
Using erubis 2.7.0
Using faraday-net_http 2.0.2
Using ruby2_keywords 0.0.5
Using faraday 2.3.0
Using ffi 1.15.5
Using jwt 2.3.0
Using google-id-token 1.4.2
Using multi_json 1.15.0
Using multi_xml 0.6.0
Using oauth2 1.4.9
Using sprockets 3.7.2
Using sprockets-rails 3.4.2
Using rails 6.0.5
Using google_sign_in 1.2.1
Using temple 0.8.2
Using tilt 2.0.10
Using haml 5.2.2
Using sexp_processor 4.16.1
Using ruby_parser 3.19.1
Using html2haml 2.2.0
Using haml-rails 2.0.1
Using honeybadger 4.12.1
Using mini_magick 4.9.5
Using ruby-vips 2.1.4
Using image_processing 1.12.2
Using jbuilder 2.11.5
Using kaminari-core 1.2.2
Using kaminari-actionview 1.2.2
Using kaminari-activerecord 1.2.2
Using kaminari 1.2.2
Using rb-fsevent 0.11.1
Using rb-inotify 0.10.1
Using ruby_dep 1.5.0
Using listen 3.1.5
Using parallel 1.22.1
Using parser 3.1.2.0
Fetching pg 1.3.5
Installing pg 1.3.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/pjhagerty/.rvm/gems/ruby-2.7.1/gems/pg-1.3.5/ext
/Users/pjhagerty/.rvm/rubies/ruby-2.7.1/bin/ruby -I /Users/pjhagerty/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0 -r ./siteconf20220516-60142-mra9d1.rb extconf.rb
--with-pg-config\=/usr/pgsql-9.1/bin/pg_config
Calling libpq with GVL unlocked
Using config values from /usr/pgsql-9.1/bin/pg_config
*** 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
    --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/pjhagerty/.rvm/rubies/ruby-2.7.1/bin/$(RUBY_BASE_NAME)
    --with-pg
    --without-pg
    --enable-gvl-unlock
    --disable-gvl-unlock
    --enable-windows-cross
    --disable-windows-cross
    --with-pg-config
extconf.rb:42:in `popen': No such file or directory - /usr/pgsql-9.1/bin/pg_config (Errno::ENOENT)
    from extconf.rb:42:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/pjhagerty/.rvm/gems/ruby-2.7.1/gems/pg-1.3.5 for inspection.
Results logged to /Users/pjhagerty/.rvm/gems/ruby-2.7.1/extensions/x86_64-darwin-20/2.7.0/pg-1.3.5/gem_make.out

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

In Gemfile:
  pg

When I check the makefile log it looks like this:

    find_executable: checking for pg_config... -------------------- no

--------------------

checking for libpq per pkg-config... -------------------- no

"pkg-config --exists libpq"
package configuration for libpq is not found
--------------------

find_header: checking for libpq-fe.h... -------------------- no

"gcc -o conftest -I/Users/pjhagerty/.rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/x86_64-darwin20 -I/Users/pjhagerty/.rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby/backward -I/Users/pjhagerty/.rvm/rubies/ruby-2.7.1/include/ruby-2.7.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/pjhagerty/.rvm/rubies/ruby-2.7.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib     -lruby.2.7   "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

"gcc -E -I/Users/pjhagerty/.rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/x86_64-darwin20 -I/Users/pjhagerty/.rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby/backward -I/Users/pjhagerty/.rvm/rubies/ruby-2.7.1/include/ruby-2.7.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens  -fno-common -pipe  conftest.c -o conftest.i"
conftest.c:3:10: fatal error: 'libpq-fe.h' file not found
#include <libpq-fe.h>
         ^~~~~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <libpq-fe.h>
/* end */

--------------------

I've seen other responses, but I can't seem to get it working.

Few things : You say your app is using Postgres 9.6. Though PG gem is looking for a file in

 extconf.rb:42:in `popen': No such file or directory - /usr/pgsql-9.1/bin/pg_config (Errno::ENOENT)
    from extconf.rb:42:in `<main>'

Which looks like PG 9.1 instead.

Also be careful, PG gem 1.3.5 (the latest version) requires PG 9.3 at least : https://github.com/ged/ruby-pg

Also if pg_config is missing it means you may need library libpq-dev (this is the name for the library in Ubuntu, if you have another system, it may change) This thread may help you : How to install PostgreSQL's pg gem on Ubuntu?

So make sure you have Postgres 9.3 + and install libpq-dev

Turns out the issue was the PATH not being correct. Had to perform a libpq reinstall

$ brew reinstall libpq

Then correct the path

$ echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> /Users/pj/.bash_profile

Now the pg gem installs properly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM