Gem Platform Issues

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.

On Thu, Feb 6, 2014 at 9:35 PM, Keith B.
[email protected]wrote:

spec.add_dependency “cv”, “>= 0.3.1”
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

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.

Never mind, it appears to work now.

Thanks for your help, Christian.

  • Keith

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 -

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?


Oh! Sorry, yes, I thought you were the same guy.

Anyway, thanks to both of you! :wink:

  • Keith

Christian is a very common name in my country

On Fri, Feb 7, 2014 at 9:24 PM, Christian MICHON
<[email protected]