【问题标题】:Postgresql gem install pg 0.18.4 passes, bundle install failsPostgresql gem install pg 0.18.4 通过,捆绑安装失败
【发布时间】:2016-04-06 15:28:06
【问题描述】:

Mac OS El Capitan

捆绑安装失败:

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.

运行 '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

但再次运行“捆绑安装”失败。有什么建议么?我试过用自制软件卸载并重新安装 postgresql,但没有成功

【问题讨论】:

标签: ruby-on-rails postgresql


【解决方案1】:

我现在在 macOS Catalina 上遇到了类似的错误,但我无法成功运行

gem install pg -v '0.18.4'

我在帮助我解决问题的 puma gem(我知道这是另一个 gem)中发现了这个问题:https://github.com/puma/puma/issues/2304

在那里,我发现了这个:

Clang 现在默认启用-Werror=implicit-function-declaration

现在,当您使用没有明确说明的函数时,Clang 会报告错误 为 macOS 构建 C 或 Objective-C 代码时的声明 (-Werror=implicit-function-declaration 标志打开)。这个额外的 错误检测统一了 Clang 对 iOS/tvOS 和 macOS 64 位的行为 此诊断的目标。 (49917738)

还有这个:

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

所以,我能够通过以下方式构建 pg

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

【讨论】:

  • 花了很多时间调试这个,你的标志为我修复了它
  • 太棒了!非常感谢!
  • 这也解决了 MacOS Big Sur 11.0 Beta 中 pg 0.18.4 的问题
  • 以下对我有用:gem install pg -v '0.18.4' -- --with-cflags="-Wno-error=implicit-function-declaration"
  • 谢谢!获救的另一位 Big Sur 用户 - 适用于 pg 1.2.3。和 Postgres 13
【解决方案2】:

所有依赖原生扩展的 gem 都面临同样的问题,例如 pgpumaffi 等 我通过-- --with-cflags="-Wno-error=implicit-function-declaration"解决了它们

例如:

  • 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"

【讨论】:

  • 这对我有用 - 更改 @haley-mnatzaganian 建议的 config 值由于某种原因没有工作
  • 确认使用 ffi 1.9.23 开发 Big Sur
【解决方案3】:

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

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

【讨论】:

  • 谢谢!我必须做一个小改动才能让它工作:bundle config build.pg '--with-cflags="-Wno-error=implicit-function-declaration"'。构建选项需要在没有额外的-- 前缀的情况下传入。请参阅bundler.io/man/bundle-config.1.html#BUILD-OPTIONS 了解更多信息。
  • 在 macOs Monterey 上,我不得不进入 ~/.bundle/config 并将其更改为 BUNDLE_BUILD__PG: "--with-cflags='-Wno-error=implicit-function-declaration'" -- bundle config 命令没有正确地转义引号。
【解决方案4】:

这不是一个答案,但它可能会为您指明正确的方向...如果确实 gem pg 已成功编译,正如您所指出的...那么您的 Ruby 项目可能不是不知何故,它指的是正确的宝石组。当您捆绑安装时,它似乎正在尝试再次安装它,如果 pg 已编译并安装在您当前的 gemset 中,则不应发生这种情况。您在系统上使用 RVM 吗?还能提供更多的输出吗?

【讨论】:

  • 好主意,但据我所知它们是相同的:jmintz-laptop:radar console$ which gem /Users/USER/.rbenv/shims/gem console$ which bundle /Users/ USER/.rbenv/shims/bundle
【解决方案5】:

答案是安装 Postgress.app 并运行

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

【讨论】:

    【解决方案6】:

    这在 sierra 上对我有用:

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

    【讨论】:

      猜你喜欢
      • 2014-09-14
      • 2012-03-03
      • 1970-01-01
      • 2017-08-27
      • 2016-04-11
      • 2021-07-11
      • 1970-01-01
      • 1970-01-01
      • 2019-11-09
      相关资源
      最近更新 更多