Postgres gem 未安装

Postgres gem not installing

我的 Mac OS X High Sierra 和 Rails 5.2 上有 postgres 10.4,但是当我尝试安装 pg gem 时,我得到一个 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 - 可能在未来)。

你 运行 Rails 使用 JRuby 的方式一直是使用 gem 'activerecord-jdbc-adapter'

但请注意,atm 不支持 5.2 - 也许在 master

上有一些工作