gem won't install on jruby #1

Closed
tmm1 opened this Issue Aug 4, 2009 · 10 comments

Comments

Projects
None yet
4 participants

tmm1 commented Aug 4, 2009

Building native extensions. This could take a while...
/custom/jruby/lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check wiki.jruby.org 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.

Owner

kanwei commented Aug 20, 2009

Will investigate this weekend.

tmm1 commented Aug 20, 2009

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

Owner

kanwei commented Aug 20, 2009

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

tmm1 commented Aug 20, 2009

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.

Owner

kanwei commented Aug 20, 2009

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

tmm1 commented Aug 20, 2009

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)

tmm1 commented Dec 24, 2010

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: https://github.com/kanwei/algorithms/blob/master/lib/algorithms/string.rb#L7

stakach commented Feb 1, 2012

gem stakach-algorithms fixes the CString issue

kanwei closed this Jan 22, 2013

Owner

kanwei commented Jan 22, 2013

Fixed for 0.6.1

kanwei reopened this Jan 22, 2013

kanwei closed this Jan 22, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment