Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

preload not called under jruby #60

Open
jeffContext opened this Issue Oct 27, 2010 · 4 comments

Comments

Projects
None yet
3 participants

I'm trying to use spork with jruby v1.5.3 and rails v3.0.1. When I run script/spork, it exits with a runtime error:

you must call Spork.using_spork! before starting the server (RuntimeError)
/hell/WebContent/WEB-INF/gems/bundler/gems/spork-729d6c0e4459/lib/spork/server.rb:25:in `listen'

This is with spork branch 729d6c0, which is 0.9.0-rc2.

Looking through the source, I saw that there is no "using_spork!" method defined anywhere. Server.rb line 25 raises the exception because Spork.using_spork? is always false.
For some reason, Spork::RunStrategy::Magazine#preload in master has commented out the line: @test_framework.preload
And calling this preload method is what eventually gets @State set to something other than :not_using_spork.

Patching this just led to other errors. Is there a way to get spork working under jruby and rails 3?

Owner

timcharper commented Oct 27, 2010

I'll ping @rdp about the issue and see what he has to comment on it. He's done the work to make jruby and spork work together.

I just tried nicksieger fork (http://github.com/nicksieger/spork). He's on the jruby team.

It got a little further, but still no luck. In his fork, it would get to "Spork is ready and listening on 8989!" and my first rspec would run quickly. But then it stops listening. The process running spork does not exit, but running rspec says "No DRb server is running. Running in local process instead"

Contributor

rdp commented Nov 5, 2010

could you try this fork?
rdp#1

Ok, I just tried jcrisp:master. Manually running it like this:

gem build spork.gemspec
gem install spork-0.8.3.gem
RAILS_ENV=test spork

Fails with this:

Using RSpec
  -- Starting to fill pool...
     Wait until at least one slave is provided before running tests...
  ** CTRL+BREAK to stop Spork and kill all ruby slave processes **
Spork is ready and listening on 8989!
Preloading Rails environment
Preloading Rails environment
/ughness/WebContent/WEB-INF/gems/gems/spork-0.8.3/lib/spork/app_framework/rails.rb:155:in `preload_rails': uninitialized constant Rails (NameError)
    from /ughness/WebContent/WEB-INF/gems/gems/spork-0.8.3/lib/spork/app_framework/rails.rb:120:in `preload'
    from /ughness/WebContent/WEB-INF/gems/gems/spork-0.8.3/lib/spork/test_framework.rb:134:in `preload'
    from /ughness/WebContent/WEB-INF/gems/gems/spork-0.8.3/lib/spork.rb:67:in `exec_prefork'
    from /ughness/WebContent/WEB-INF/gems/gems/spork-0.8.3/lib/spork/test_framework.rb:120:in `preload'
    from ./magazine_slave.rb:27:in `preload'
    from ./magazine_slave.rb:15:in `initialize'
    from magazine_slave_provider.rb:21:in `new'
    from magazine_slave_provider.rb:21
/ughness/WebContent/WEB-INF/gems/gems/spork-0.8.3/lib/spork/app_framework/rails.rb:155:in `preload_rails': uninitialized constant Rails (NameError)
    from /ughness/WebContent/WEB-INF/gems/gems/spork-0.8.3/lib/spork/app_framework/rails.rb:120:in `preload'
    from /ughness/WebContent/WEB-INF/gems/gems/spork-0.8.3/lib/spork/test_framework.rb:134:in `preload'
    from /ughness/WebContent/WEB-INF/gems/gems/spork-0.8.3/lib/spork.rb:67:in `exec_prefork'
    from /ughness/WebContent/WEB-INF/gems/gems/spork-0.8.3/lib/spork/test_framework.rb:120:in `preload'
    from ./magazine_slave.rb:27:in `preload'
    from ./magazine_slave.rb:15:in `initialize'
    from magazine_slave_provider.rb:21:in `new'
    from magazine_slave_provider.rb:21
   -- build slave 1...
   -- build slave 2...

A bit of tracing shows that it's not getting past boot.rb. So for my next attempt, I patched the spork gem to load environment.rb rather than boot.rb.
Gemfile updated to:

gem 'spork', :git => 'git://github.com/jcrisp/spork.git', :ref => "96423d9462b7669f2cec"

Run it with:

RAILS_ENV=test bundle exec spork

It gets farther--it seems to successfully preloads rails, but then spork's attempt to include NinjaPatcher raises this:

/ughness/WebContent/WEB-INF/gems/bundler/gems/spork-96423d9462b7/lib/spork/app_framework/rails.rb:7:in `class_eval': undefined method `load_environment' for module `Rails::Initializer' (NameError)
    from /ughness/WebContent/WEB-INF/gems/bundler/gems/spork-96423d9462b7/lib/spork/app_framework/rails.rb:7:in `included'
    from /ughness/WebContent/WEB-INF/gems/bundler/gems/spork-96423d9462b7/lib/spork/app_framework/rails.rb:159:in `preload_rails'
    from /ughness/WebContent/WEB-INF/gems/bundler/gems/spork-96423d9462b7/lib/spork/app_framework/rails.rb:121:in `preload'
    from /ughness/WebContent/WEB-INF/gems/bundler/gems/spork-96423d9462b7/lib/spork/test_framework.rb:134:in `preload'
    from /ughness/WebContent/WEB-INF/gems/bundler/gems/spork-96423d9462b7/lib/spork.rb:67:in `exec_prefork'
    from /ughness/WebContent/WEB-INF/gems/bundler/gems/spork-96423d9462b7/lib/spork/test_framework.rb:120:in `preload'
    from ./magazine_slave.rb:27:in `preload'
    from ./magazine_slave.rb:15:in `initialize'
    from magazine_slave_provider.rb:21:in `new'
    from magazine_slave_provider.rb:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment