mrbrdo / theine

Rails preloader for JRuby (similar to Zeus, Spring and Spork)
MIT License
99 stars 10 forks source link

Rake does not work #8

Closed djmaze closed 10 years ago

djmaze commented 10 years ago

At least with JRuby 1.7.6 and Rails 3.2.16, it is not possible to run rake through theine. Steps to reproduce:

rbenv local jruby-1.7.6
export JRUBY_OPTS=--1.9
gem install rails
rails new theine_test
cd theine_test
theine_server

In a second terminal:

# Working
theine rails c
# Not working
theine rake -T

The following error is shown when running theine rake:

NoMethodError: undefined method `namespace' for main:Object
           (root) at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:4
             load at org/jruby/RubyKernel.java:1101
           (root) at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:1
  load_dependency at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:236
             load at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:245
             load at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:245
    instance_exec at org/jruby/RubyBasicObject.java:1565
          Railtie at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/activerecord-3.2.16/lib/active_record/railtie.rb:34
             each at org/jruby/RubyArray.java:1613
       load_tasks at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/railties-3.2.16/lib/rails/railtie.rb:194
       load_tasks at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/railties-3.2.16/lib/rails/railtie.rb:194
             each at org/jruby/RubyArray.java:1613
       load_tasks at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/railties-3.2.16/lib/rails/engine.rb:423
              all at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/railties-3.2.16/lib/rails/application/railties.rb:8
       load_tasks at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/railties-3.2.16/lib/rails/engine.rb:423
           Worker at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/theine-0.0.14/lib/theine/worker.rb:14
    instance_exec at org/jruby/RubyBasicObject.java:1565
       __ensure__ at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/theine-0.0.14/lib/theine/worker.rb:50
              run at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/theine-0.0.14/lib/theine/worker.rb:44
           (root) at /home/martin/.rbenv/versions/jruby-1.7.6/lib/ruby/gems/shared/gems/theine-0.0.14/lib/theine/worker.rb:142

I tried with JRuby in 2.0 mode, too. Same error.

mrbrdo commented 10 years ago

I have had this issue before at one point, but even before I started working on theine. Are you sure this only occurs when running through theine?

djmaze commented 10 years ago

Yes, bundle exec rake -T is working. Also, I can reproduce the error in another app of mine.

Sounds like the rake file is not recognized as such, see answer on SO.

mrbrdo commented 10 years ago

Well I let Rails take care of all the work, so I'm not exactly sure what could be going on here, it worked fine when I used it. I will definitely look at it, but it might take some time before I can work on it. If you want to take a stab, try bundle open theine (if you have it in Gemfile), and open lib/theine/worker.rb. All the relevant lines related to the rake task are 13-27.

Also you can first try to put theine in your Gemfile and run theine_server with bundle exec, if you didn't do this already.

mrbrdo commented 10 years ago

I've noticed you are running Rails 3 - I have not tested with Rails 3. I will review and accept pull requests related to Rails 3 but I don't have time to support it myself. I just tested theine rake on two of my projects (Rails 4) and it worked for both.

If you find this is not a Rails3-only issue, let me know and I will reopen.