5

I am trying to use the JRuby Heroku buildpack (https://github.com/jruby/heroku-buildpack-jruby) to run a simple test application.

However, it seems that gems with C extensions cannot be compiled. For example, when doing a "git push heroku", the gems without C extensions are installed successfully, but then...

   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

Upon seeing the advice given above, I then went and created a modified version of the JRuby buildpack, which can be found here: https://github.com/grahamdaley/heroku-buildpack-jruby-cext

The only difference between this buildpack and the original one is that I have now set JRUBY_OPTS as follows:

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

However, this doesn't seem to have made any difference at all and I'm still getting the same error.

Any hints? Is it possible (and would help) to add a .jrubyrc file somewhere in the buildpack?

2 Answers2

1

you should simply configure JRUBY_OPTS instead of a setting up a customized build-pack :

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

that being said - it's probably a bad idea to use C-ext with JRuby

you definitely do not need C-ext due to BSON gem (it has a native JRuby version) - editing your Gemfile and/or re-bundling (rm Gemfile.lock && bundle) locally with JRuby will likely solve this for you ...

kares
  • 7,076
  • 1
  • 28
  • 38
0

Install without C extention

On way is just install json without the C extension. Is possible because the C extension is optional. Attention this is slower than bson with C extension this is may a problem for you. source

Ruby — with optional C extension

Open a Ticket

Almost any gem - even those with native dependencies - can be installed using Bundler. If there’s a specific gem that won’t install on Heroku, please submit a support ticket.

So you can open a support ticket here

Community
  • 1
  • 1
Sir l33tname
  • 4,026
  • 6
  • 38
  • 49