Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


gem won't install on jruby #1

tmm1 opened this Issue · 10 comments

4 participants


Building native extensions. This could take a while...
/custom/jruby/lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check for alternatives. (NotImplementedError)
from /custom/jruby/lib/ruby/1.8/mkmf.rb:1:in `require'
from extconf.rb:1
ERROR: Error installing algorithms:
ERROR: Failed to build gem native extension.


Will investigate this weekend.


JRuby does not support extensions, to build a jruby gem, simply:

spec.extensions = nil
spec.platform = 'java'

and you'll get a (pure-ruby) jruby compatible algorithms-0.2.0-java.gem


Any way to automate this so jruby users get the extension-less gem while everyone else gets extensions?


I think you have to generate separate gems, but you can put if RUBY_PLATFORM =~ /java/ checks in the gemspec so jruby -S gem build algorithms.gemspec builds the jruby version.


If I generate the separate gem, will pushing that onto rubyforge automatically result in the selection choices when installing gems?


If you set .platform='java', jgem and gem will pick and install the appropriate gems correctly.


I use rvm and jruby 1.5.6. I followed the above procedure. Gem was packaged and installed nicely. However, I get the following error when I try to run my code:

/home/vatikiot/.rvm/rubies/jruby-1.5.6/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require': no such file to load -- CString (LoadError)


This is due to the addition of Algorithm::String in fb40819

You could add a java version of the Levenshtein distance algorithm, or simply wrap the following code in a unless RUBY_PLATFORM =~ /java/ to disable it:


gem stakach-algorithms fixes the CString issue

@kanwei kanwei closed this

Fixed for 0.6.1

@kanwei kanwei reopened this
@kanwei kanwei closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.