简体   繁体   English

Postgresql gem install pg 0.18.4 通过,捆绑安装失败

[英]Postgresql gem install pg 0.18.4 passes, bundle install fails

Mac OS El Capitan 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:运行 'gem install pg -v '0.18.4' 结果:

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我试过用自制软件卸载并重新安装 postgresql,但没有成功

I have got a similar error now on macOS Catalina, but I was not able to successfully run我现在在 macOS Catalina 上遇到了类似的错误,但我无法成功运行

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 .我在puma gem(我知道这是另一个 gem)中发现了这个问题,它帮助我解决了这个问题: https : //github.com/puma/puma/issues/2304

There, I found this:在那里,我发现了这个:

Clang now enables -Werror=implicit-function-declaration by default: Clang 现在默认启用-Werror=implicit-function-declaration

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).当您在为 macOS 构建 C 或 Objective-C 代码时使用没有显式声明的函数时,Clang 现在会报告错误( -Werror=implicit-function-declaration标志已打开)。 This additional error detection unifies Clang's behavior for iOS/tvOS and macOS 64-bit targets for this diagnostic.这种额外的错误检测将 Clang 针对 iOS/tvOS 和 macOS 64 位目标的行为统一起来,以进行此诊断。 (49917738) (49917738)

And this:而这个:

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

So, I was able to build pg with:因此,我能够使用以下命令构建pg

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

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"所有依赖本机扩展(如pgpumaffi等)的 gem 都面临同样的问题,我通过传递-- --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"

在运行bundle之前,我必须将 Benito 的答案和 jasonm 的答案结合起来,如下所示(归功于 Unixmonkey):

bundle config build.pg '-- --with-cflags="-Wno-error=implicit-function-declaration"'

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.这不是一个答案,因此,但它可能会为您指明正确的方向……如果 gem pg 确实已成功编译,正如您所指出的那样……那么您的 Ruby 项目可能不是指不知何故,正确的宝石。 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.当您 bundle install 时,它似乎试图再次安装它,如果 pg 已经编译并安装在您当前的 gemset 中,则不会发生这种情况。 Are you using RVM on your system?您是否在系统上使用 RVM? Can you also provide more output?你还能提供更多的输出吗?

答案是安装 Postgress.app 并运行

  bundle config build.pg --with-pg-config=[Path to pg_config] before bundling

这在 sierra 上对我有用:

gem install pg -v '0.18.3' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM