【问题标题】:Failed to build gem native extension with JRuby无法使用 JRuby 构建 gem 原生扩展
【发布时间】:2012-06-05 09:45:10
【问题描述】:

我使用 ruby-build 将 ruby​​ 版本从 ruby​​ 1.9.3-p125 更改为 JRuby 1.7.0-preview1。当我在我的项目上执行jruby -S bundle install 时,出现如下错误,

...
Using bson (1.6.2) 
Installing bson_ext (1.6.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/joshchang/.rbenv/versions/jruby-1.7.0-preview1/bin/jruby extconf.rb 
NotImplementedError: C extension support is not enabled. Pass -Xcext.enabled=true to JRuby or set JRUBY_OPTS or modify .jrubyrc to enable.

   (root) at /Users/joshchang/.rbenv/versions/jruby-1.7.0-preview1/lib/ruby/shared/mkmf.rb:8
  require at org/jruby/RubyKernel.java:991
   (root) at /Users/joshchang/.rbenv/versions/jruby-1.7.0-preview1/lib/ruby/shared/rubygems/custom_require.rb:1
   (root) at extconf.rb:1
...

有什么建议吗?谢谢。

【问题讨论】:

    标签: ruby-on-rails jruby bundler jrubyonrails


    【解决方案1】:

    JRUBY_OPTS="-Xcext.enabled=true" gem install <your gem> 应该可以工作!

    【讨论】:

      【解决方案2】:

      只需阅读错误消息并按照上面的说明尝试:jruby -Xcext.enabled=true -S bundle install 虽然它可能不起作用 - 通常 JRuby 不支持 C 扩展。

      【讨论】:

      • 你确实需要检查你的包依赖关系,找出为什么使用 bson_ext gem(gem 'bson' 单独在 JRuby 上应该没问题)并禁用它或声明它依赖于平台,例如gem 'bson_ext', :platform => :ruby。但这都是猜测,如果您向我们展示您的 Gemfile,我们可能会解决这个问题...
      猜你喜欢
      • 1970-01-01
      • 2015-07-20
      • 2015-06-18
      • 2016-03-08
      • 2012-07-26
      • 2014-10-25
      • 2023-03-17
      • 1970-01-01
      相关资源
      最近更新 更多