6

I think I may have found a bug in Warbler, but I wanted to post this here as a question in case there's something I'm doing wrong. In a nutshell, any attempt to take a jruby app that requires the 'bson' gem an package it into a .jar file with warbler fails. Here's the error that I get, every time:

LoadError: no such file to load -- jar:file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/gems/bson-1.8.0-java/lib/../ext/java/jar/mongo-2.6.5 ...

Here's a very simple set of steps to reproduce the problem on OS X or Linux:

Make a 'wartest' dir and cd into it

Using bundler, make a new jruby-1.6.7.2 gemset called 'wartest'. Then do 'rvm use jruby-1.6.7.2@wartest'

Install warbler and bundler:

jruby --1.9 -S gem install warbler
jruby --1.9 -S gem install bundler

And just to confirm that it works:

which warble
#=> /Users/jstokes/.rvm/gems/jruby-1.6.7.2@wartest/bin/warble

Now create the following, two-line Gemfile:

#Gemfile
source 'http://rubygems.org'
gem 'bson'

Now 'bundle install'

Now make a bin directory and create the file bin/main.rb. Then paste in the following:

#bin/main.rb
require 'bson'
puts 'It worked!'

At this point, we're ready to create the jar file. So do

jruby --1.9 -S warble jar
#=> rm -f wartest.jar
#=> Creating wartest.jar

Now for the moment of truth:

java -jar wartest.jar
#=> It worked!

So what's the problem? The problem is that if you change to another gemset, or use system ruby, it's going to blow up. Observe:

rvm use system
#=> Now using system ruby.
java -jar wartest.jar
LoadError: no such file to load -- jar:file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/gems/bson-1.8.0-java/lib/../ext/java/jar/mongo-2.6.5
  require at org/jruby/RubyKernel.java:1027
  require at jar:file:/var/folders/xr/nmvhn6x566v6xkw9l7pgpkj40000gn/T/jruby5567740032767770706extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36
   (root) at jar:file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/gems/bson-1.8.0-java/lib/bson.rb:53
  require at org/jruby/RubyKernel.java:1027
   (root) at jar:file:/var/folders/xr/nmvhn6x566v6xkw9l7pgpkj40000gn/T/jruby5567740032767770706extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1
  require at jar:file:/var/folders/xr/nmvhn6x566v6xkw9l7pgpkj40000gn/T/jruby5567740032767770706extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:60
     load at org/jruby/RubyKernel.java:1046
   (root) at file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/wartest/bin/main.rb:1
  require at org/jruby/RubyKernel.java:1027
   (root) at file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/META-INF/main.rb:1
   (root) at file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/META-INF/main.rb:1

If I go back and jar xf wartest.jar, and go into the gems/bson-1.8.0-java dir, the mongo-2.6.5.jar file exists and is in the right place. But for some crazy reason, it just can't be found. This happens every time, on both Ubuntu and OS X. If someone knows what I'm doing wrong, please tell me. Otherwise I'll file a bug report.

And if I file a bug report, whose bug is this? I presume that it's a warbler bug, but I'm not seeing it with any other gem besides bson (and mongo, which depends on bson).

unwind
  • 391,730
  • 64
  • 469
  • 606
Jon Stokes
  • 213
  • 2
  • 7

0 Answers0