LoginSignup
2
2

More than 1 year has passed since last update.

postgresqlのbundle installができない(sh: /usr/bin/pg_config: No such file or directory)

Posted at

エラー内容

新規プロジェクト作成時、

rails new . --database=postgresql --skip-test

をした後、bundle installをしようとしたらできなかった🤯

 

# エラー全文

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/apple/workspace/runteq/muscle_beat/vendor/bundle/ruby/3.0.0/gems/pg-1.2.3/ext
/Users/apple/.rbenv/versions/3.0.2/bin/ruby -I /Users/apple/.rbenv/versions/3.0.2/lib/ruby/3.0.0 -r
./siteconf20220111-87208-7szvjs.rb extconf.rb --with-pg-config\=/usr/bin/pg_config
Using config values from /usr/bin/pg_config
sh: /usr/bin/pg_config: No such file or directory
sh: /usr/bin/pg_config: No such file or directory
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQsetSingleRowMode()... yes
checking for PQconninfo()... yes
checking for PQsslAttribute()... yes
checking for PQresultVerboseErrorMessage()... yes
checking for PQencryptPasswordConn()... yes
checking for PQresultMemorySize()... yes
checking for timegm()... yes
checking for rb_gc_adjust_memory_usage()... yes
checking for unistd.h... yes
checking for inttypes.h... yes
checking for C99 variable length arrays... yes
creating extconf.h
creating Makefile

current directory: /Users/apple/workspace/runteq/muscle_beat/vendor/bundle/ruby/3.0.0/gems/pg-1.2.3/ext
make DESTDIR\= clean

current directory: /Users/apple/workspace/runteq/muscle_beat/vendor/bundle/ruby/3.0.0/gems/pg-1.2.3/ext
make DESTDIR\=
compiling gvl_wrappers.c
compiling pg.c
compiling pg_binary_decoder.c
compiling pg_binary_encoder.c
compiling pg_coder.c
pg_coder.c:216:34: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        res = this->dec_func(this, val, RSTRING_LEN(argv[0]), tuple, field, ENCODING_GET(argv[0]));
              ~~~~                      ^~~~~~~~~~~~~~~~~~~~
/Users/apple/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:44:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
1 warning generated.
compiling pg_connection.c
pg_connection.c:679:17: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        return INT2NUM(atol(port));
               ~~~~~~~ ^~~~~~~~~~
1 warning generated.
compiling pg_copy_coder.c
pg_copy_coder.c:228:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                                        strlen = RSTRING_LEN(subint);
                                               ~ ^~~~~~~~~~~~~~~~~~~
/Users/apple/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:44:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
pg_copy_coder.c:534:23: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                input_len = end_ptr - start_ptr;
                          ~ ~~~~~~~~^~~~~~~~~~~
2 warnings generated.
compiling pg_errors.c
compiling pg_record_coder.c
pg_record_coder.c:196:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                                        strlen = RSTRING_LEN(subint);
                                               ~ ^~~~~~~~~~~~~~~~~~~
/Users/apple/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:44:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
1 warning generated.
compiling pg_result.c
pg_result.c:1006:17: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        return INT2NUM(n);
               ~~~~~~~ ^
pg_result.c:1590:58: warning: 'rb_cData' is deprecated: by: rb_cObject.  Will be removed in 3.1. [-Wdeprecated-declarations]
        rb_cPGresult = rb_define_class_under( rb_mPG, "Result", rb_cData );
                                                                ^
/Users/apple/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rdata.h:173:18: note: expanded from macro 'rb_cData'
#define rb_cData rb_cData()
                 ^
/Users/apple/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rdata.h:166:1: note: 'rb_cData' has been explicitly marked
deprecated here
RBIMPL_ATTR_DEPRECATED(("by: rb_cObject.  Will be removed in 3.1."))
^
/Users/apple/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/attr/deprecated.h:32:53: note: expanded from macro
'RBIMPL_ATTR_DEPRECATED'
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__ msg))
                                                    ^
2 warnings generated.
compiling pg_text_decoder.c
compiling pg_text_encoder.c
pg_text_encoder.c:194:14: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                        len = out - start;
                            ~ ~~~~^~~~~~~
pg_text_encoder.c:406:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                return optr - out;
                ~~~~~~ ~~~~~^~~~~
pg_text_encoder.c:410:12: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                return 2 + RSTRING_LEN(*intermediate) * 2;
                ~~~~~~ ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pg_text_encoder.c:617:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        nr_elems = RARRAY_LEN(value);
                 ~ ^~~~~~~~~~~~~~~~~
/Users/apple/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rarray.h:52:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len
                                   ^
4 warnings generated.
compiling pg_tuple.c
pg_tuple.c:482:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        num_fields = RARRAY_LEN(values);
                   ~ ^~~~~~~~~~~~~~~~~~
/Users/apple/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rarray.h:52:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len
                                   ^
1 warning generated.
compiling pg_type_map.c
compiling pg_type_map_all_strings.c
compiling pg_type_map_by_class.c
compiling pg_type_map_by_column.c
pg_type_map_by_column.c:161:52: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        return dec_func( p_coder, RSTRING_PTR(field_str), RSTRING_LEN(field_str), 0, fieldno, enc_idx );
               ~~~~~~~~                                   ^~~~~~~~~~~~~~~~~~~~~~
/Users/apple/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:44:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
pg_type_map_by_column.c:230:17: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        conv_ary_len = RARRAY_LEN(conv_ary);
                     ~ ^~~~~~~~~~~~~~~~~~~~
/Users/apple/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rarray.h:52:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len
                                   ^
2 warnings generated.
compiling pg_type_map_by_mri_type.c
compiling pg_type_map_by_oid.c
compiling pg_type_map_in_ruby.c
compiling pg_util.c
pg_util.c:119:24: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        return (char*)out_ptr - out;
        ~~~~~~ ~~~~~~~~~~~~~~~^~~~~
1 warning generated.
linking shared-object pg_ext.bundle
ld: warning: argument missing after -rpath
ld: file not found: dynamic_lookup
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [pg_ext.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/apple/workspace/runteq/muscle_beat/vendor/bundle/ruby/3.0.0/gems/pg-1.2.3 for inspection.
Results logged to
/Users/apple/workspace/runteq/muscle_beat/vendor/bundle/ruby/3.0.0/extensions/x86_64-darwin-20/3.0.0/pg-1.2.3/gem_make.out

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:
  pg

 

原因

結論から言うと、
pg_configのパスが指定されていなかったから!

解決方法

.bundle/configに以下を追記

BUNDLE_BUILD__PG: "--with-pg-config\\=/usr/local/bin/pg_config"

その後、

bundle install

で無事できました✌️

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2