Kyle
Kyle

Reputation: 1278

JRuby + minitest failing because of ObjectSpace

I am new to JRuby, and I'm trying to get my test suite running correctly. I'm using minitest, and it looks like minitest requires the ObjectSpace to be enabled. I've tried each of the following commands:

bundle exec jruby -X+O -S rake
jruby -X+O -S bundle exec rake
JRUBY_OPTS="-X+O" bundle exec rake
export JRUBY_OPTS="-X+O" && bundle exec rake

and all of them result in the following stack trace:

RuntimeError: ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable
each_object at org/jruby/RubyObjectSpace.java:167
     each at org/jruby/RubyEnumerator.java:189
     to_a at org/jruby/RubyEnumerable.java:375
      AWS at /Users/kshipley/.rvm/gems/jruby-1.6.2@split/bundler/gems/papi-38fc7d34a33d/lib/papi/aws.rb:1476
     Papi at /Users/kshipley/.rvm/gems/jruby-1.6.2@split/bundler/gems/papi-38fc7d34a33d/lib/papi/aws.rb:6
   (root) at /Users/kshipley/.rvm/gems/jruby-1.6.2@split/bundler/gems/papi-38fc7d34a33d/lib/papi/aws.rb:5
  require at org/jruby/RubyKernel.java:1038
   (root) at /Users/kshipley/.rvm/gems/jruby-1.6.2@split/bundler/gems/papi-38fc7d34a33d/lib/papi/aws.rb:157
  require at org/jruby/RubyKernel.java:1038
  require at /Users/kshipley/.rvm/gems/jruby-1.6.2@split/bundler/gems/papi-38fc7d34a33d/lib/papi.rb:68
     each at org/jruby/RubyArray.java:1602
  require at /Users/kshipley/.rvm/gems/jruby-1.6.2@global/gems/bundler-1.0.15/lib/bundler/runtime.rb:66
     each at org/jruby/RubyArray.java:1602
  require at /Users/kshipley/.rvm/gems/jruby-1.6.2@global/gems/bundler-1.0.15/lib/bundler/runtime.rb:55
  require at /Users/kshipley/.rvm/gems/jruby-1.6.2@global/gems/bundler-1.0.15/lib/bundler.rb:120
   (root) at /Users/kshipley/work/src/split/config/environment.rb:5
  require at org/jruby/RubyKernel.java:1038
   (root) at /Users/kshipley/work/src/split/config/environment.rb:3
  require at org/jruby/RubyKernel.java:1038
   (root) at /Users/kshipley/work/src/split/test/test_helper.rb:1
     load at org/jruby/RubyKernel.java:1063
 __file__ at /Users/kshipley/.rvm/gems/jruby-1.6.2@split/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
     each at org/jruby/RubyArray.java:1602
   (root) at /Users/kshipley/.rvm/gems/jruby-1.6.2@split/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!

Any ideas what the proper command is to re-enable the ObjectSpace when running rake? I have run commands like

bundle exec jruby -X+O test/functional/my_test.rb
bundle exec jruby -X+O -S irb

with no issues, so it seems somehow related to rake specifically.

Upvotes: 2

Views: 810

Answers (1)

banzaiman
banzaiman

Reputation: 2663

Does your rake task spawn subprocesses? If so, JRuby might be reusing the current JVM process. Try exporting JRUBY_OPTS='-X+O -J-Djruby.launch.inproc=false'.

Upvotes: 4

Related Questions