Postgres宝石没有安装

时间:2018-05-23 20:22:20

标签: ruby-on-rails postgresql jruby

我在Mac OS X High Sierra和Rails 5.2上有postgres 10.4,但是当我尝试安装pg gem时,我得到了一个gem building错误。尽管成功确认了pg_config,但它表示无法构建gem。我希望有人能看到这个错误并指出我正确的方向吗?

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 */

1 个答案:

答案 0 :(得分:1)

你无法在JRuby上真正安装任何本机C宝石。

通常是特定于平台的版本(共享相同名称的单独的gem版本),例如如果你检查nokogiri,你会看到几个1.8.2版本。

对于pg,没有java平台版本(但在1.0.0中 - 可能在将来)。

使用JRuby运行Rails的方式是使用 gem&#39; activerecord-jdbc-adapter&#39;

但请注意5.2不支持atm - 也许有些工作在主