Yosemite - SQLite3 gem 安装错误 - 不支持 C 扩展

Yosemite - SQLite3 gem installation error - C extensions not supported

我想在jruby 项目中使用SQLite3。

gem install SQLite3

命令失败

Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    /Users/h1k3n/.rvm/rubies/jruby-9.0.0.0/bin/jruby -r ./siteconf20150809-4559-7o84f5.rb extconf.rb
NotImplementedError: C extensions are not supported
    <top> at /Users/h1k3n/.rvm/rubies/jruby-9.0.0.0/lib/ruby/stdlib/mkmf.rb:1
  require at org/jruby/RubyKernel.java:940
   (root) at /Users/h1k3n/.rvm/rubies/jruby-9.0.0.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
    <top> at extconf.rb:3

extconf failed, exit code 1

Gem files will remain installed in /Users/h1k3n/.rvm/gems/jruby-9.0.0.0/gems/sqlite3-1.3.10 for inspection.
Results logged to /Users/h1k3n/.rvm/gems/jruby-9.0.0.0/extensions/universal-java-1.8/2.2.0/sqlite3-1.3.10/gem_make.out

gcc 版本

which gcc => /usr/bin/gcc

正在尝试安装 SQLite3

brew instal SQLite3 => Warning: sqlite-3.8.11 already installed

已安装 SQLite3 版本

which SQLite3 => ~/Android/sdk/platform-tools/sqlite3

我认为这是罪魁祸首。它可能指向 SQLite3 的 Android 版本而不是系统版本,这就是它无法构建本机扩展的原因。

您似乎在使用 JRuby, not the standard Ruby implementation, Ruby MRI

SQLite3 gem relies on Ruby C extensions, but unlike the standard implementation, JRuby does not support Ruby C extensions:

JRuby versions prior to 1.6 did not support Ruby C extensions, and even in 1.6 the support is still "in development" and considered experimental. As of 1.7, it has been disabled and will likely be removed.

上面的文章列出了替代 gem 的建议,包括 SQLite3。