我正在从ruby-2.5.7迁移到jruby-9.2.12.0,在更改bundle install
后运行ruby-version & gemfile
时,我在pg-gem中出错。
Installing pg 1.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/kush/.rvm/gems/jruby-9.2.12.0/gems/pg-1.2.3/ext
/Users/kush/.rvm/rubies/jruby-9.2.12.0/bin/jruby -I
/Users/kush/.rvm/rubies/jruby-9.2.12.0/lib/ruby/stdlib -r
./siteconf20200707-6808-16ipijl.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/kush/.rvm/rubies/jruby-9.2.12.0/lib/ruby/stdlib/mkmf.rb:456
try_link0 at
/Users/kush/.rvm/rubies/jruby-9.2.12.0/lib/ruby/stdlib/mkmf.rb:541
try_link at
/Users/kush/.rvm/rubies/jruby-9.2.12.0/lib/ruby/stdlib/mkmf.rb:556
<main> at extconf.rb:40
*** extconf.rb failed ***
我已经安装了开发人员工具,并且在Mac中也装有Xcode。
我们非常感谢您的帮助!
答案 0 :(得分:0)
pg
宝石高度特定于MRI(即“标准”红宝石),并且与JRuby不兼容。因此,您应该在此处使用其他数据库适配器。
JRuby中最常用的适配器基于JDBC。有针对大多数数据库数据库类型的JRuby包装器。要使用与Rails一起使用的PostgreSQL适配器,可以将其与activerecord-jdbcpostgresql-adapter
gem一起使用。为此,替换
gem "pg"
在您的Gemfile
上行
gem "activerecord-jdbcpostgresql-adapter"
有关配置和用法的详细信息,请参见https://github.com/jruby/activerecord-jdbc-adapter/blob/master/README.md。