Reputation: 1052
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
Upvotes: 42
Views: 11466
Reputation: 194
I had to combine Benito's answer and jasonm's answer like below before running bundle
(credit to Unixmonkey):
bundle config build.pg '-- --with-cflags="-Wno-error=implicit-function-declaration"'
Upvotes: 16
Reputation: 291
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"
Upvotes: 26
Reputation: 1381
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"
Upvotes: 112
Reputation: 305
this worked for me on sierra:
gem install pg -v '0.18.3' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
Upvotes: 0
Reputation: 1052
Answer was installing Postgress.app and running
bundle config build.pg --with-pg-config=[Path to pg_config] before bundling
Upvotes: 0
Reputation: 126
This isn't an an answer, as such, but it may point you in the right direction... If indeed gem pg has successfully compiled, as you have indicated... Then it maybe that your Ruby project isn't referring to the correct gemset, somehow. As it appears it is attempting to install it again when you bundle install, this should not happen if pg has been compiled and installed in your current gemset. Are you using RVM on your system? Can you also provide more output?
Upvotes: 0