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
然而再次运行'bundle install'失败了。有什么建议?我已经尝试卸载并重新安装带有自制程序的postgresql但没有运气
答案 0 :(得分:40)
我现在在macOS Catalina上也遇到了类似的错误,但是我无法成功运行
gem install pg -v '0.18.4'
我在puma
宝石(我知道这是另一个宝石)中发现了这个问题,该问题帮助我解决了这个问题: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"
答案 1 :(得分:7)
所有依赖于本机扩展(例如pg
,puma
,ffi
等)的gem都面临着相同的问题
我通过传递-- --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"
答案 2 :(得分:1)
在运行bundle
(贷记到Unixmonkey)之前,我不得不像下面那样组合Benito的答案和jasonm的答案:
bundle config build.pg '-- --with-cflags="-Wno-error=implicit-function-declaration"'
答案 3 :(得分:0)
这不是一个答案,因此,它可能会指向正确的方向......如果确实宝石pg已成功编译,正如您所指出的......那么可能您的Ruby项目不是'无论如何,指的是正确的宝石。因为看起来它正在尝试在捆绑安装时再次安装它,如果pg已经编译并安装在当前的gemset中,则不会发生这种情况。您在系统上使用RVM吗?你还可以提供更多的输出吗?
答案 4 :(得分:0)
答案是安装Postgress.app并运行
bundle config build.pg --with-pg-config=[Path to pg_config] before bundling
答案 5 :(得分:0)
这对我在山脉上起作用了:
AMAZON_API_KEY = "abcxyz123987"
DB_CREDENTIALS = {
'database': 'fancy_reporting_db
'user': 'etl_user',
'host': 'localhost',
'password': 'password'
}