'Creating new app with rails trying to connect postgresql- error occurred while installing pg
I am trying to create a rails app with postgres and I keep going in circles getting the same errors. I've been scouring the internet for the past two days trying everything and cannot get it to work. Can someone please help me figure this out? I am brand new to rails and new to coding in general.
Here is me first trying to create the app with postgresql as the database:
(base) Queen@MacBook-Air rails % rails new testing --database=postgresql
create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create .gitattributes
create Gemfile
run git init from "."
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /Users/Queen/Documents/rails/testing/.git/
...
remove config/initializers/cors.rb
remove config/initializers/new_framework_defaults_7_0.rb
run bundle install
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Using rake 13.0.6
Using racc 1.6.0
Using crass 1.0.6
Using minitest 5.15.0
Using builder 3.2.4
Using digest 3.1.0
Using timeout 0.2.0
Using strscan 3.0.1
Using concurrent-ruby 1.1.10
Using websocket-extensions 0.1.5
Using marcel 1.0.2
Using bundler 2.3.11
Using erubi 1.10.0
Using rack 2.2.3
Using nio4r 2.5.8
Using io-console 0.5.11
Using bindex 0.8.1
Using msgpack 1.5.1
Using mini_mime 1.1.2
Using matrix 0.4.2
Using rexml 3.2.5
Using rubyzip 2.3.2
Using nokogiri 1.13.4 (arm64-darwin)
Using net-protocol 0.1.3
Using i18n 1.10.0
Using tzinfo 2.0.4
Fetching pg 1.3.5
Using childprocess 4.1.0
Using rack-test 1.1.0
Using sprockets 4.0.3
Using public_suffix 4.0.7
Using puma 5.6.4
Using method_source 1.0.0
Using loofah 2.16.0
Using mail 2.7.1
Using net-imap 0.2.3
Using websocket-driver 0.7.5
Using zeitwerk 2.5.4
Using net-smtp 0.3.1
Using bootsnap 1.11.1
Using thor 1.2.1
Using selenium-webdriver 4.1.0
Using regexp_parser 2.3.0
Using addressable 2.8.0
Using rails-html-sanitizer 1.4.2
Using activesupport 7.0.2.3
Using net-pop 0.1.1
Using webdrivers 5.0.0
Using xpath 3.2.0
Using rails-dom-testing 2.0.3
Using capybara 3.36.0
Using activemodel 7.0.2.3
Using globalid 1.0.0
Using actionview 7.0.2.3
Using reline 0.3.1
Using activejob 7.0.2.3
Using actionpack 7.0.2.3
Using irb 1.4.1
Using jbuilder 2.11.5
Using sprockets-rails 3.4.2
Using actioncable 7.0.2.3
Using activerecord 7.0.2.3
Using actionmailer 7.0.2.3
Using railties 7.0.2.3
Using debug 1.5.0
Using activestorage 7.0.2.3
Using importmap-rails 1.0.3
Using stimulus-rails 1.0.4
Using actionmailbox 7.0.2.3
Using web-console 4.2.0
Using actiontext 7.0.2.3
Using turbo-rails 1.0.1
Using rails 7.0.2.3
Installing pg 1.3.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/Users/Queen/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.3.5/ext
/Users/Queen/.asdf/installs/ruby/3.1.2/bin/ruby -I
/Users/Queen/.asdf/installs/ruby/3.1.2/lib/ruby/site_ruby/3.1.0 -r
./siteconf20220418-88114-drsbsc.rb extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
checking for whether -Wl,-rpath,/usr/local/lib is accepted as LDFLAGS... yes
Using libpq from /usr/local/lib
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... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*****************************************************************************
Unable to find PostgreSQL client library.
Please install libpq or postgresql client package like so:
brew install libpq
or try again with:
gem install pg -- --with-pg-config=/path/to/pg_config
or set library paths manually with:
gem install pg -- --with-pg-include=/path/to/libpq-fe.h/
--with-pg-lib=/path/to/libpq.so/
*** 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.
...
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
/Users/Queen/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/extensions/arm64-darwin-21/3.1.0/pg-1.3.5/mkmf.log
extconf failed, exit code 1
...
An error occurred while installing pg (1.3.5), and Bundler cannot
continue.
In Gemfile:
pg
run bundle binstubs bundler
Could not find gem 'pg (~> 1.1)' in locally installed gems.
rails importmap:install
Could not find gem 'pg (~> 1.1)' in locally installed gems.
Run `bundle install` to install missing gems.
rails turbo:install stimulus:install
Could not find gem 'pg (~> 1.1)' in locally installed gems.
Run `bundle install` to install missing gems.
I then tried to do what it said with gem install pg -- --with-pg-config=/path/to/pg_config. Here is what happened:
(base) Queen@MacBook-Air ~ % ls /usr/local/bin
2to3 jest pg_restore
2to3-3.7 msgattrib pg_rewind
acountry msgcat pg_test_fsync
adig msgcmp pg_test_timing
ahost msgcomm pg_upgrade
autoconf msgconv pg_verifybackup
autoheader msgen pg_waldump
autom4te msgexec pgbench
autopoint msgfilter pip3
autoreconf msgfmt pip3.7
autoscan msggrep pkg-config
autoupdate msginit postgres
brew msgmerge postmaster
brotli msgunfmt psql
clusterdb msguniq pydoc3
createdb ngettext pydoc3.7
createuser nodemon python3
dropdb npm python3-config
dropuser npx python3.7
easy_install-3.7 oid2name python3.7-config
ecpg pcre2-config python3.7m
envsubst pcre2grep python3.7m-config
gettext pcre2test pyvenv
gettext.sh pg_amcheck pyvenv-3.7
gettextize pg_archivecleanup rbenv
git pg_basebackup rbenv-install
git-cvsserver pg_checksums rbenv-uninstall
git-receive-pack pg_config recode-sr-latin
git-shell pg_controldata reindexdb
git-upload-archive pg_ctl ruby-build
git-upload-pack pg_dump surge
heroku pg_dumpall vacuumdb
idle3 pg_isready vacuumlo
idle3.7 pg_receivewal xgettext
ifnames pg_recvlogical yarn
initdb pg_resetwal yarnpkg
(base) Queen@MacBook-Air ~ % gem install pg --with-pg-config=/usr/local/bin/pg_config
ERROR: While executing gem ... (Gem::OptionParser::InvalidOption)
invalid option: --with-pg-config=/usr/local/bin/pg_config
(base) Queen@MacBook-Air ~ % gem install pg -- --with-pg-config=/usr/local/bin/pg_config
Building native extensions with: '--with-pg-config=/usr/local/bin/pg_config'
This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /Users/Queen/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.3.5/ext
/Users/Queen/.asdf/installs/ruby/3.1.2/bin/ruby -I /Users/Queen/.asdf/installs/ruby/3.1.2/lib/ruby/site_ruby/3.1.0 -r ./siteconf20220418-90925-oiasjs.rb extconf.rb --with-pg-config\=/usr/local/bin/pg_config
Calling libpq with GVL unlocked
Using config values from /usr/local/bin/pg_config
checking for whether -Wl,-rpath,/usr/local/lib is accepted as LDFLAGS... yes
Using libpq from /usr/local/lib
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... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*****************************************************************************
Unable to find PostgreSQL client library.
Please install libpq or postgresql client package like so:
brew install libpq
or try again with:
gem install pg -- --with-pg-config=/path/to/pg_config
or set library paths manually with:
gem install pg -- --with-pg-include=/path/to/libpq-fe.h/ --with-pg-lib=/path/to/libpq.so/
*** 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.
...
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/Queen/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/extensions/arm64-darwin-21/3.1.0/pg-1.3.5/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/Queen/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.3.5 for inspection.
Results logged to /Users/Queen/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/extensions/arm64-darwin-21/3.1.0/pg-1.3.5/gem_make.out
I then opened up the log where it said to check why it failed and got this:
block in append_ldflags: checking for whether -Wl,-rpath,/usr/local/lib is accepted as LDFLAGS... -------------------- yes
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/Queen/.asdf/installs/ruby/3.1.2/lib "clang -o
...
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/Queen/.asdf/installs/ruby/3.1.2/lib "clang -o conftest -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0 -I. -I/usr/local/include -I/Users/Queen/.asdf/installs/ruby/3.1.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef -fno-common -pipe conftest.c -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -L/usr/local/lib -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -fstack-protector-strong -L/usr/local/lib -lruby.3.1 -Wl,-rpath,/usr/local/lib "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return !!argv[argc];
6: }
/* end */
--------------------
find_header: checking for libpq-fe.h... -------------------- yes
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/Queen/.asdf/installs/ruby/3.1.2/lib "clang -
...
--------------------
find_header: checking for libpq/libpq-fs.h... -------------------- yes
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/Queen/.asdf/installs/ruby/3.1.2/lib "clang -
...
--------------------
find_header: checking for pg_config_manual.h... -------------------- yes
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/Queen/.asdf/installs/ruby/3.1.2/lib "clang -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/arm64-darwin21 -
...
--------------------
have_library: checking for PQconnectdb() in -lpq... -------------------- no
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/Queen/.asdf/installs/ruby/3.1.2/lib "clang -o conftest -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0 -I. -I/usr/local/include -I/Users/Queen/.asdf/installs/ruby/3.1.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef -fno-common -pipe conftest.c -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -L/usr/local/lib -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -fstack-protector-strong -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lruby.3.1 -lpq "
ld: warning: ignoring file /usr/local/lib/libpq.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
"_PQconnectdb", referenced from:
_t in conftest-1d6349.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: int (* volatile tp)(void)=(int (*)(void))&t;
11: printf("%d", (*tp)());
12: }
13:
14: return !!argv[argc];
15: }
16: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return !p; }
/* end */
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/Queen/.asdf/installs/ruby/3.1.2/lib "clang -o conftest -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0 -I. -I/usr/local/include -I/Users/Queen/.asdf/installs/ruby/3.1.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef -fno-common -pipe conftest.c -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -L/usr/local/lib -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -fstack-protector-strong -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lruby.3.1 -lpq "
conftest.c:16:13: error: conflicting types for 'PQconnectdb'
extern void PQconnectdb();
^
/usr/local/include/libpq-fe.h:285:16: note: previous declaration is here
extern PGconn *PQconnectdb(const char *conninfo);
^
conftest.c:17:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
~~~~~~~~~~~ ^
/usr/local/include/libpq-fe.h:285:16: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
^
2 errors generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: int (* volatile tp)(void)=(int (*)(void))&t;
11: printf("%d", (*tp)());
12: }
13:
14: return !!argv[argc];
15: }
16: extern void PQconnectdb();
17: int t(void) { PQconnectdb(); return 0; }
/* end */
--------------------
have_library: checking for PQconnectdb() in -llibpq... -------------------- no
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/Queen/.asdf/installs/ruby/3.1.2/lib "clang -o conftest -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0 -I. -I/usr/local/include -I/Users/Queen/.asdf/installs/ruby/3.1.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef -fno-common -pipe conftest.c -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -L/usr/local/lib -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -fstack-protector-strong -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lruby.3.1 -llibpq "
ld: library not found for -llibpq
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: int (* volatile tp)(void)=(int (*)(void))&t;
11: printf("%d", (*tp)());
12: }
13:
14: return !!argv[argc];
15: }
16: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return !p; }
/* end */
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/Queen/.asdf/installs/ruby/3.1.2/lib "clang -o conftest -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0 -I. -I/usr/local/include -I/Users/Queen/.asdf/installs/ruby/3.1.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef -fno-common -pipe conftest.c -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -L/usr/local/lib -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -fstack-protector-strong -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lruby.3.1 -llibpq "
conftest.c:16:13: error: conflicting types for 'PQconnectdb'
extern void PQconnectdb();
^
/usr/local/include/libpq-fe.h:285:16: note: previous declaration is here
extern PGconn *PQconnectdb(const char *conninfo);
^
conftest.c:17:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
~~~~~~~~~~~ ^
/usr/local/include/libpq-fe.h:285:16: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
^
2 errors generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: int (* volatile tp)(void)=(int (*)(void))&t;
11: printf("%d", (*tp)());
12: }
13:
14: return !!argv[argc];
15: }
16: extern void PQconnectdb();
17: int t(void) { PQconnectdb(); return 0; }
/* end */
--------------------
have_library: checking for PQconnectdb() in -lms/libpq... -------------------- no
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/Queen/.asdf/installs/ruby/3.1.2/lib "clang -o conftest -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0 -I. -I/usr/local/include -I/Users/Queen/.asdf/installs/ruby/3.1.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef -fno-common -pipe conftest.c -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -L/usr/local/lib -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -fstack-protector-strong -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lruby.3.1 -lms/libpq "
ld: library not found for -lms/libpq
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: int (* volatile tp)(void)=(int (*)(void))&t;
11: printf("%d", (*tp)());
12: }
13:
14: return !!argv[argc];
15: }
16: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return !p; }
/* end */
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/Queen/.asdf/installs/ruby/3.1.2/lib "clang -o conftest -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/Queen/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0 -I. -I/usr/local/include -I/Users/Queen/.asdf/installs/ruby/3.1.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef -fno-common -pipe conftest.c -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -L/usr/local/lib -L. -L/Users/Queen/.asdf/installs/ruby/3.1.2/lib -fstack-protector-strong -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lruby.3.1 -lms/libpq "
conftest.c:16:13: error: conflicting types for 'PQconnectdb'
extern void PQconnectdb();
^
/usr/local/include/libpq-fe.h:285:16: note: previous declaration is here
extern PGconn *PQconnectdb(const char *conninfo);
^
conftest.c:17:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
~~~~~~~~~~~ ^
/usr/local/include/libpq-fe.h:285:16: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
^
2 errors generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: int (* volatile tp)(void)=(int (*)(void))&t;
11: printf("%d", (*tp)());
12: }
13:
14: return !!argv[argc];
15: }
16: extern void PQconnectdb();
17: int t(void) { PQconnectdb(); return 0; }
/* end */
I'm lost. I've tried brew update, brew install postgresql, gem install pg and brew install libpq. Please help. I used a mac install guide for ruby on rails located here: https://mac.install.guide/rubyonrails/12.html I have an M1 Macbook Air running on MacOS Monterey Version 12.3.1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
