Forum: JRuby Gem Platform Issues

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
0d1cd73bfe0ebe09074bfcd138ed3d5d?d=identicon&s=25 Keith B. (keith_b)
on 2014-02-06 22:36
(Received via mailing list)
All -

I wrote a gem that calls a Java library using RVM if running under MRI
Ruby, and just calls the Java library in the same (J)Ruby VM when
in JRuby.

I've built the gem in JRuby, installed it, and required it in (a JRuby)
irb, successfully.

However, I have another gem that is dependent on it, and I can't get it
to try to build rjb.

I have a feeling it has something to do with the gemspec, but I'm not
sure.  Assuming my gem's name is 'cv' (it's not), here's what I think is
the relevant code in the gemspec:

  is_jruby = /java/ === RUBY_PLATFORM
  spec.platform = 'java' if is_jruby

  if is_jruby
    spec.add_dependency "cv", ">= 0.3.1"
    spec.add_dependency "cv", ">= 0.1.0"
    spec.add_dependency "yajl-ruby"  # For JSON parsing

Any idea what I might be doing wrong?  The error message I get when
bundler is below.


/Users/kbennett/.rvm/rubies/jruby-1.7.10/bin/jruby extconf.rb
/Users/kbennett/.rvm/rubies/jruby-1.7.10/lib/ruby/shared/mkmf.rb:14: Use
RbConfig instead of obsolete and deprecated Config.
mkmf.rb can't find header files for ruby at

extconf failed, uncaught signal 1

Gem files will remain installed in
/Users/kbennett/.rvm/gems/jruby-1.7.10/gems/rjb-1.4.9 for inspection.
Results logged to
An error occurred while installing rjb (1.4.9), and Bundler cannot
Make sure that `gem install rjb -v '1.4.9'` succeeds before bundling.
christian (Guest)
on 2014-02-07 12:22
(Received via mailing list)
On Thu, Feb 6, 2014 at 9:35 PM, Keith Bennett

> spec.add_dependency "cv", ">= 0.3.1"
>   else
>     spec.add_dependency "cv", ">= 0.1.0"

both statements will use the latest cv gem, at least on clean local gem

are there two cv one for MRI and one for java, i.e. how does the
look like ?

the install of gem should honor the current platform and install the
respective platform gem if available.

- christian
Christian MICHON (Guest)
on 2014-02-07 12:49
(Received via mailing list)
Road to hell... Why don't you generate 2 versions? 1 MRI specific and 1
java platform.

If you've tests in your gems, you'll need also to handle RUBY_PLATFORM
run the tests for each platform, switching environments in your shell.
you use RVM, you might even confuse this more...

If you've 2 versions (one for each platform), you need to test on each
platform only what is specific.
0d1cd73bfe0ebe09074bfcd138ed3d5d?d=identicon&s=25 Keith B. (keith_b)
on 2014-02-07 17:58
(Received via mailing list)
Christian -

Thanks for responding.  The cv.gemspec includes:

  is_jruby = /java/ === RUBY_PLATFORM
  if is_jruby
    spec.platform = 'java'
  unless is_jruby
    spec.add_dependency 'rjb'
    spec.add_development_dependency "pry-debugger"

When I build the gem, the Java version is named cv-0.4.3-java.gem. (The
"-java" is appended automatically.)

In my other gemspec, do I have to explicitly specify that I want a Java
version of the gem, or should it automatically find it if spec.platform

There are 2 separate versions of the gem created -- is that what you
in your second message?

0d1cd73bfe0ebe09074bfcd138ed3d5d?d=identicon&s=25 Keith B. (keith_b)
on 2014-02-07 20:39
(Received via mailing list)
Never mind, it appears to work now.

Thanks for your help, Christian.

- Keith
Christian MICHON (Guest)
on 2014-02-07 22:27
(Received via mailing list)
The 2nd message is from me. 2 Christians replied.

Glad that the solution worked. And yes I meant for 2 versions of the gem
be created, instead of a generic.
christian (Guest)
on 2014-02-07 23:04
(Received via mailing list)
Christian is a very common name in my country

On Fri, Feb 7, 2014 at 9:24 PM, Christian MICHON
0d1cd73bfe0ebe09074bfcd138ed3d5d?d=identicon&s=25 Keith B. (keith_b)
on 2014-02-08 19:20
(Received via mailing list)
Oh!  Sorry, yes, I thought you were the same guy.

Anyway, thanks to both of you! ;)

- Keith
This topic is locked and can not be replied to.