我的Mac OS X High Sierra和Rails 5.2上有postgres 10.4,但是当我尝试安装pg gem时,我遇到了gem构建错误。它说,尽管成功确认了pg_config,但它无法建造宝石。我希望有人能看到错误并指出我正确的方向?
cdougherty1242m% gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /Users/cdougherty/.rvm/gems/jruby-9.1.13.0/gems/pg-1.0.0/ext
/Users/cdougherty/.rvm/rubies/jruby-9.1.13.0/bin/jruby -r ./siteconf20180523-76754-a2cdps.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.
try_do at /Users/cdougherty/.rvm/rubies/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:456
try_link0 at /Users/cdougherty/.rvm/rubies/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:541
try_link at /Users/cdougherty/.rvm/rubies/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:556
<main> at extconf.rb:40
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/cdougherty/.rvm/gems/jruby-9.1.13.0/extensions/universal-java-1.8/2.3.0/pg-1.0.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/cdougherty/.rvm/gems/jruby-9.1.13.0/gems/pg-1.0.0 for inspection.
Results logged to /Users/cdougherty/.rvm/gems/jruby-9.1.13.0/extensions/universal-java-1.8/2.3.0/pg-1.0.0/gem_make.out
这是来自 mfmk 日志的猫,如果它有帮助的话。
find_executable: checking for pg_config... -------------------- yes
" -o conftest -I/include/universal-java1.8 -I/Users/cdougherty/.rvm/rubies/jruby-9.1.13.0/lib/ruby/include/ruby/backward -I/Users/cdougherty/.rvm/rubies/jruby-9.1.13.0/lib/ruby/include -I. -I/usr/local/Cellar/postgresql/10.4/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fPIC -DTARGET_RT_MAC_CFM=0 -fno-omit-frame-pointer -fno-strict-aliasing -fexceptions conftest.c -L. -L/Users/cdougherty/.rvm/rubies/jruby-9.1.13.0/lib -L/usr/local/lib -arch x86_64 "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <ruby.h>
4: int main(int argc, char **argv)
5: {
6: return 0;
7: }
/* end */
你不能在JRuby上安装任何原生的C gems。
通常有特定于平台的版本(共享相同名称的单独 Gem 版本(,例如,如果您检查 Nokogiri,您会看到几个 1.8.2 版本。
对于PG,没有Java平台版本(在1.0.0中 - 也许在未来
(。你用JRuby运行Rails的方式是使用gem'activerecord-jdbc-adapter'
但请注意,不支持 5.2 ATM - 也许在 master 上进行了一些工作