【问题标题】:Building gems with jRuby cext on Heroku在 Heroku 上使用 jRuby cext 构建 gems
【发布时间】:2012-10-27 02:34:47
【问题描述】:

我正在尝试使用 JRuby Heroku buildpack (https://github.com/jruby/heroku-buildpack-jruby) 来运行一个简单的测试应用程序。

但是,带有 C 扩展名的 gem 似乎无法编译。比如在做“git push heroku”的时候,没有C扩展的gem安装成功,但是之后...

   Using activerecord (3.1.3) 
   Using activeresource (3.1.3) 
   Using bouncy-castle-java (1.5.0146.1) 
   Using bson (1.7.0) 
   Installing bson_ext (1.7.0) with native extensions 
   Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

           /tmp/build_10vcxrs9ayvxf/jruby/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 /tmp/build_10vcxrs9ayvxf/jruby/lib/ruby/shared/mkmf.rb:8
     require at org/jruby/RubyKernel.java:1019
      (root) at /tmp/build_10vcxrs9ayvxf/jruby/lib/ruby/shared/rubygems/custom_require.rb:1
      (root) at extconf.rb:1


   Gem files will remain installed in /tmp/build_10vcxrs9ayvxf/vendor/bundle/jruby/1.9/gems/bson_ext-1.7.0 for inspection.
   Results logged to /tmp/build_10vcxrs9ayvxf/vendor/bundle/jruby/1.9/gems/bson_ext-1.7.0/ext/cbson/gem_make.out
   An error occurred while installing bson_ext (1.7.0), and Bundler cannot continue.
   Make sure that `gem install bson_ext -v '1.7.0'` succeeds before bundling.
   Dependencies installed

在看到上面给出的建议后,我创建了 JRuby buildpack 的修改版本,可以在这里找到:https://github.com/grahamdaley/heroku-buildpack-jruby-cext

这个 buildpack 和原来的唯一区别是我现在设置了 JRUBY_OPTS 如下:

JRUBY_OPTS="--1.9 -Xcext.enabled=true -J-Xmx400m"

但是,这似乎根本没有任何区别,我仍然遇到同样的错误。

有什么提示吗?是否可以(并且会有所帮助)在 buildpack 的某个位置添加 .jrubyrc 文件?

【问题讨论】:

  • 您的 github 链接已损坏。

标签: heroku jruby buildpack


【解决方案1】:

您应该简单地配置 JRUBY_OPTS 而不是设置自定义构建包:

heroku config:add JRUBY_OPTS="--1.9 -Xcext.enabled=true -J-Xmx400m"

话虽如此 - 将 C-ext 与 JRuby 一起使用可能是个坏主意

由于 BSON gem(它有一个native JRuby 版本),您绝对不需要 C-ext - 使用 JRuby 在本地编辑您的 Gemfile 和/或重新捆绑 (rm Gemfile.lock && bundle) 将可能会为您解决这个问题...

【讨论】:

    【解决方案2】:

    安装无 C 扩展

    方法只是安装没有 C 扩展名的 json。是可能的,因为 C 扩展是可选的。注意这比带有 C 扩展名的 bson 慢,这对你来说可能是个问题。 source

    Ruby — 带有可选的 C 扩展

    开票

    几乎所有的gem——甚至是那些有本地依赖的——都可以使用Bundler进行安装。如果有特定的 gem 无法在 Heroku 上安装,请提交支持票。

    所以你可以打开支持票here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-09
      • 2017-01-21
      • 1970-01-01
      相关资源
      最近更新 更多