Error when installing pg 0.15.1 on os x - ruby

This is what happens when I try to install the latest version of Postgres gem on OS X Lion.
$ gem install pg
Upgraded http://rubygems.org/ to HTTPS
Fetching: pg-0.15.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/.rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /Applications/Postgres.app/Contents/MacOS/bin/pg_config
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 PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQescapeLiteral()... yes
checking for PQescapeIdentifier()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for PQlibVersion()... yes
checking for PQping()... yes
checking for PQsetSingleRowMode()... yes
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... yes
checking for rb_thread_call_without_gvl()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_fd_select()... yes
checking for rb_w32_wrap_io_handle()... no
checking for PGRES_COPY_BOTH in libpq-fe.h... no
checking for PGRES_SINGLE_TUPLE in libpq-fe.h... no
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
creating extconf.h
creating Makefile
make
compiling gvl_wrappers.c
compiling pg.c
pg.c: In function ‘pg_s_library_version’:
pg.c:273: warning: implicit declaration of function ‘PQlibVersion’
pg.c: In function ‘Init_pg_ext’:
pg.c:384: error: ‘PQPING_OK’ undeclared (first use in this function)
pg.c:384: error: (Each undeclared identifier is reported only once
pg.c:384: error: for each function it appears in.)
pg.c:386: error: ‘PQPING_REJECT’ undeclared (first use in this function)
pg.c:388: error: ‘PQPING_NO_RESPONSE’ undeclared (first use in this function)
pg.c:390: error: ‘PQPING_NO_ATTEMPT’ undeclared (first use in this function)
make: *** [pg.o] Error 1
Gem files will remain installed in /.rvm/gems/ruby-2.0.0-p0#myapp/gems/pg-0.15.1 for inspection.
Results logged to /.rvm/gems/ruby-2.0.0-p0#myapp/gems/pg-0.15.1/ext/gem_make.out
How do I fix this?

try to do a install of PG by doing
brew install postgresql
then try to rerun the bundle see if that works

Related

Failed to build gem native extension on macOS

I want to run this workflow called TarSynFlow (https://github.com/seoanezonjic/TarSynFlow). It has some requirements that I am trying to install, but am hitting some issues, specifically with installing scbi_distributed_blast. The TarSynFlow github page and original source (https://github.com/dariogf/scbi_distributed_blast) for this say to type:
gem install scbi_distributed_blast
Tried this but get the following:
Building native extensions. This could take a while...
ERROR: Error installing scbi_distributed_blast:
ERROR: Failed to build gem native extension.
current directory: /Users/user_name/.rvm/gems/ruby-3.0.0/gems/eventmachine-1.2.7/ext
/Users/ginamchaput/.rvm/rubies/ruby-3.0.0/bin/ruby -I
/Users/ginamchaput/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0 -r ./siteconf20210830-52462-idkyvy.rb extconf.rb
checking for -lcrypto... yes
checking for -lssl... yes
checking for openssl/ssl.h... yes
checking for openssl/err.h... yes
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_fd_select()... yes
checking for rb_fdset_t in ruby/intern.h... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for pipe2() in unistd.h... no
checking for accept4() in sys/socket.h... no
checking for SOCK_CLOEXEC in sys/socket.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for clock_gettime()... yes
checking for CLOCK_MONOTONIC_RAW in time.h... yes
checking for CLOCK_MONOTONIC in time.h... yes
CXXFLAGS= -Wall -Wextra -Wno-deprecated-declarations -Wno-ignored-qualifiers -Wno-unused-result -Wno-address
creating Makefile
current directory: /Users/user_name/.rvm/gems/ruby-3.0.0/gems/eventmachine-1.2.7/ext
make "DESTDIR=" clean
current directory: /Users/user_name/.rvm/gems/ruby-3.0.0/gems/eventmachine-1.2.7/ext
make "DESTDIR="
compiling binder.cpp
In file included from binder.cpp:20:
./project.h:119:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
^~~~~~~~~~~~~~~
1 error generated.
make: *** [binder.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/user_name/.rvm/gems/ruby-3.0.0/gems/eventmachine-1.2.7 for inspection.
Results logged to /Users/user_name/.rvm/gems/ruby-3.0.0/extensions/x86_64-darwin-20/3.0.0/eventmachine-1.2.7/gem_make.out
I did see other posts suggest using sudo gem install scbi_distributed_blast ; I did try it but same error.
I'm using macOS Big Sur; XCode v 12.5.1; ruby (installed via RVM) v 3.0.0p0; If anyone has advice to get this installed that would be great!
From this:
./project.h:119:10: fatal error: 'openssl/ssl.h' file not found
looks like you need ssl dev libraries to compile the gem. If you have xcode installed, try with:
xcode-select --install
Another way to install the required libs is to use homebrew with:
brew install openssl
brew link openssl --force
Update
If you have all the required libraries installed, then try installing eventmachine by itself, but specifying the path where the ssl libraries are located.
gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
then, try installing scbi_distributed_blast again.

RubyGems Error while installing Jekyll 'openssl/ssl.h' file not found

I am trying to install Jekyll on my Mac (gem install jekyll) using RubyGems but I'm running into the error below.
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
current directory: /Users/nikhilanand/.rvm/gems/ruby-3.0.2/gems/eventmachine-1.2.7/ext
/Users/nikhilanand/.rvm/rubies/ruby-3.0.2/bin/ruby -I /Users/nikhilanand/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0 -r ./siteconf20210816-54247-5zijii.rb extconf.rb
checking for -lcrypto... yes
checking for -lssl... yes
checking for openssl/ssl.h... yes
checking for openssl/err.h... yes
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_fd_select()... yes
checking for rb_fdset_t in ruby/intern.h... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for pipe2() in unistd.h... no
checking for accept4() in sys/socket.h... no
checking for SOCK_CLOEXEC in sys/socket.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for clock_gettime()... yes
checking for CLOCK_MONOTONIC_RAW in time.h... yes
checking for CLOCK_MONOTONIC in time.h... yes
CXXFLAGS= -Wall -Wextra -Wno-deprecated-declarations -Wno-ignored-qualifiers -Wno-unused-result -Wno-address
creating Makefile
current directory: /Users/nikhilanand/.rvm/gems/ruby-3.0.2/gems/eventmachine-1.2.7/ext
make DESTDIR\= clean
current directory: /Users/nikhilanand/.rvm/gems/ruby-3.0.2/gems/eventmachine-1.2.7/ext
make DESTDIR\=
compiling binder.cpp
In file included from binder.cpp:20:
./project.h:119:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
^~~~~~~~~~~~~~~
1 error generated.
make: *** [binder.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/nikhilanand/.rvm/gems/ruby-3.0.2/gems/eventmachine-1.2.7 for inspection.
Results logged to /Users/nikhilanand/.rvm/gems/ruby-3.0.2/extensions/arm64-darwin-20/3.0.0/eventmachine-1.2.7/gem_make.out
I tried brew install openssl but it says that openssl is already installed, and I also tried gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include but I'm getting the same error 'openssl/ssl.h' file not found.
Could someone point out how to fix this issue here?
You might need to run brew link --force openssl first.
Then gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
I had the same issue and this worked for me:
gem install eventmachine -v '1.2.7' -- --with-cppflags=-I/usr/local/opt/openssl/include
I had to specify the version. Without it, it still failed 🤷

Can't install pg gem on Yosemite

I am trying to bundle install my Gemfile at Yosemite, I have pg listed, but I get this error:
Installing pg 0.18.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/Apple/.rvm/rubies/ruby-2.2.2/bin/ruby -r ./siteconf20150811-78520-18pzkkt.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/local/php5/bin/pg_config
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 PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQescapeLiteral()... yes
checking for PQescapeIdentifier()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for PQlibVersion()... yes
checking for PQping()... yes
checking for PQsetSingleRowMode()... yes
checking for PQconninfo()... yes
checking for PQhostaddr()... no
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... yes
checking for rb_thread_call_without_gvl()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_fd_select()... yes
checking for rb_w32_wrap_io_handle()... no
checking for rb_str_modify_expand()... yes
checking for rb_hash_dup()... yes
checking for PGRES_COPY_BOTH in libpq-fe.h... yes
checking for PGRES_SINGLE_TUPLE in libpq-fe.h... yes
checking for PG_DIAG_TABLE_NAME in libpq-fe.h... yes
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
creating extconf.h
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
compiling pg_binary_decoder.c
compiling pg_binary_encoder.c
compiling pg_coder.c
compiling pg_connection.c
compiling pg_copy_coder.c
compiling pg_errors.c
compiling pg_result.c
compiling pg_text_decoder.c
compiling pg_text_encoder.c
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
compiling pg_type_map_by_mri_type.c
compiling pg_type_map_by_oid.c
compiling pg_type_map_in_ruby.c
compiling util.c
linking shared-object pg_ext.bundle
couldn't understand kern.osversion `14.1.0'
ld: warning: directory not found for option '-L/Users/haven/.sm/pkg/active/lib'
ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: ld returned 1 exit status
Makefile:253: recipe for target 'pg_ext.bundle' failed
make: *** [pg_ext.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/Apple/.rvm/gems/ruby-2.2.2#/gems/pg-0.18.1 for inspection.
Results logged to /Users/Apple/.rvm/gems/ruby-2.2.2#/extensions/x86_64-darwin-14/2.2.0-static/pg-0.18.1/gem_make.out
An error occurred while installing pg (0.18.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.1'` succeeds before bundling.
Any one can help?
i had plenty of problems installing pg gem in a fresh SO until i found this:
bundle failing - Can't find the PostgreSQL client library (libpq)
hope this helps you.

gem install pg error: couldn't understand kern.osversion `14.0.0' on Yosemite w/ Ruby 2.1.5

I used RVM to install Ruby-2.1.5 and ran bundle again. Now the pg gem won't install and I get this error:
gem install pg -v '0.17.1' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config'
This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/diego/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20141120-33258-108chh6.rb extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
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 PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQescapeLiteral()... yes
checking for PQescapeIdentifier()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for PQlibVersion()... yes
checking for PQping()... yes
checking for PQsetSingleRowMode()... yes
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... yes
checking for rb_thread_call_without_gvl()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_fd_select()... yes
checking for rb_w32_wrap_io_handle()... no
checking for PGRES_COPY_BOTH in libpq-fe.h... yes
checking for PGRES_SINGLE_TUPLE in libpq-fe.h... yes
checking for PG_DIAG_TABLE_NAME in libpq-fe.h... yes
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
creating extconf.h
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
compiling pg_connection.c
compiling pg_errors.c
compiling pg_result.c
linking shared-object pg_ext.bundle
couldn't understand kern.osversion `14.0.0'
ld: warning: directory not found for option '-L/Users/mpapis/.sm/pkg/active/lib'
ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: ld returned 1 exit status
make: *** [pg_ext.bundle] Error 1
make failed, exit code 2
I've updated XCode to version 6.1 via the App Store. I reinstalled gcc and applegcc-4.2 via homebrew. I also reinstall Postgres.app. I've tried the suggested solutions here and here to no avail.
Anybody have any idea what to try next? For now I'm just reverting to Ruby-2.1.4 where pg installs fine.
If you set MACOSX_DEPLOYMENT_TARGET=10.9 in your environment prior to compiling the pg gem, the shared object linking should work properly.

Trouble installing pg gem

Trying to install the pg gem gives me errors.
I'm using Ruby 1.9.3-p125 built using rbenv/ruby-build. I installed PostgreSQL using the one-click installer. I'm able to connect to the DB using pgAdmin. I'm running out of ideas.
% gem install pg ~
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/sandropadin/.rbenv/versions/1.9.3-p125/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
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 PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... yes
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
creating extconf.h
creating Makefile
make
compiling pg.c
compiling pg_connection.c
pg_connection.c: In function ‘pgconn_wait_for_notify’:
pg_connection.c:1986: warning: ‘rb_thread_select’ is deprecated (declared at /Users/sandropadin/.rbenv/versions/1.9.3-p125/include/ruby-1.9.1/ruby/intern.h:379)
pg_connection.c: In function ‘pgconn_block’:
pg_connection.c:2512: warning: ‘rb_thread_select’ is deprecated (declared at /Users/sandropadin/.rbenv/versions/1.9.3-p125/include/ruby-1.9.1/ruby/intern.h:379)
compiling pg_result.c
linking shared-object pg_ext.bundle
ld: in /usr/local/lib/libssl.0.9.8.dylib, missing required architecture x86_64 in file for architecture x86_64
collect2: ld returned 1 exit status
make: *** [pg_ext.bundle] Error 1
Gem files will remain installed in /Users/sandropadin/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/pg-0.13.2 for inspection.
Results logged to /Users/sandropadin/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/pg-0.13.2/ext/gem_make.out
Not sure which of the following steps finally cleared this issue up. But as mu is too short mentioned, the problem was mixing 32bit and 64bit binaries.
1st, I installed this 64-bit version of PostgreSQL
2nd, I uninstalled any old Homebrew OpenSSL installation
$ brew uninstall openssl
3rd, I installed the 64-bit version of OpenSSL with Homebrew
$ brew install --64-bit openssl
Lastly, when installing the pg gem, I changed the LDFLAGS to point to the 64-bit version of OpenSSL
$ gem install pg -- --with-ldflags='-L/usr/local/Cellar/openssl/0.9.8s'

Resources