Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql gem install pg 0.18.4 passes, bundle install fails

Mac OS El Capitan

Bundle install fails with:

compiling pg_connection.c pg_connection.c:2394:3: warning: implicit declaration of function 'gettimeofday' is invalid in C99 [-Wimplicit-function-declaration]                 gettimeofday(&currtime, NULL);                 ^ 1 warning generated. 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 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/jmintz/Documents/LaunchAngels/radar/vendor/bundle/gems/pg-0.18.4 for inspection. Results logged to /Users/jmintz/Documents/LaunchAngels/radar/vendor/bundle/extensions/x86_64-darwin-15/2.2.0-static/pg-0.18.4/gem_make.out 

... ...

An error occurred while installing pg (0.18.4), and Bundler cannot continue.  Make sure that `gem install pg -v '0.18.4'` succeeds before bundling. 

Running 'gem install pg -v '0.18.4' results in:

Building native extensions.  This could take a while... Successfully installed pg-0.18.4 Parsing documentation for pg-0.18.4 Done installing documentation for pg after 4 seconds 1 gem installed 

Yet running 'bundle install' again fails. Any suggestions? I've tried uninstalling and reinstalling postgresql with homebrew with no luck

like image 294
jasonm Avatar asked Apr 06 '16 15:04

jasonm


2 Answers

I have got a similar error now on macOS Catalina, but I was not able to successfully run

gem install pg -v '0.18.4' 

I found this issue in the puma gem (I know this is another gem) that helped me solve the issue: https://github.com/puma/puma/issues/2304.

There, I found this:

Clang now enables -Werror=implicit-function-declaration by default:

Clang now reports an error when you use a function without an explicit declaration when building C or Objective-C code for macOS (-Werror=implicit-function-declaration flag is on). This additional error detection unifies Clang’s behavior for iOS/tvOS and macOS 64-bit targets for this diagnostic. (49917738)

And this:

gem install puma:4.3.5 -- --with-cflags="-Wno-error=implicit-function-declaration" 

So, I was able to build pg with:

gem install pg -v '0.18.1' -- --with-cflags="-Wno-error=implicit-function-declaration" 
like image 112
Benito Serna Avatar answered Sep 25 '22 19:09

Benito Serna


The same issue has been faced with all the gems that rely on native extensions such as pg, puma, ffi, etc I have solved them by passing -- --with-cflags="-Wno-error=implicit-function-declaration"

ex:

  • gem install pg -v '0.18.4' -- --with-cflags="-Wno-error=implicit-function-declaration"

  • gem install ffi -v '1.12.2' -- --with-cflags="-Wno-error=implicit-function-declaration"

  • gem install puma -v '4.3.1' -- --with-cflags="-Wno-error=implicit-function-declaration"

like image 28
MaJeD BoJaN Avatar answered Sep 26 '22 19:09

MaJeD BoJaN