New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PadrinoTasks.use(:mongoid) raises NameError in rake #1125

Closed
contentfree opened this Issue Mar 15, 2013 · 6 comments

Comments

Projects
None yet
4 participants
@contentfree

contentfree commented Mar 15, 2013

It's as if the environment isn't loaded (at least bundler/setup hasn't run).

I'm using mongoid 3.1, the current (as of today) revision of Padrino from the repo, and my Rakefile looks like:

require 'padrino-core/cli/rake'

PadrinoTasks.use(:mongoid)
PadrinoTasks.use(:database)
PadrinoTasks.init

The error is:

 bin/rake -T -t
rake aborted!
uninitialized constant Mongoid
/Users/dave/.rvm/gems/ruby-1.9.3-p286/bundler/gems/padrino-framework-9ed3ca33d23e/padrino-gen/lib/padrino-gen/padrino-tasks/mongoid.rb:4:in `block in <top (required)>'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task_manager.rb:196:in `in_namespace'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/dsl_definition.rb:104:in `namespace'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/bundler/gems/padrino-framework-9ed3ca33d23e/padrino-gen/lib/padrino-gen/padrino-tasks/mongoid.rb:2:in `<top (required)>'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/default_loader.rb:6:in `load'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:651:in `load_imports'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/bundler/gems/padrino-framework-9ed3ca33d23e/padrino-core/lib/padrino-core/cli/rake.rb:12:in `init'
/Users/dave/Sites/vpe/public-api/Rakefile:5:in `<top (required)>'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:583:in `raw_load_rakefile'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:89:in `block in load_rakefile'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:88:in `load_rakefile'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:72:in `block in run'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/dave/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
bin/rake:16:in `load'
bin/rake:16:in `<main>'
@contentfree

This comment has been minimized.

Show comment
Hide comment
@contentfree

contentfree Mar 15, 2013

Prefacing PadrinoTasks.use(:mongoid) with require 'mongoid' fixes it for me and is a (temporary?) workaround.

I'm guessing the problem is that the tasks themselves are dependent on :environment and therefore Mongoid (nor the rest of the environment) is loaded.

Another question is how does it even get past the PadrinoTasks.load? call in padrino-tasks/mongoid.rb:2?

contentfree commented Mar 15, 2013

Prefacing PadrinoTasks.use(:mongoid) with require 'mongoid' fixes it for me and is a (temporary?) workaround.

I'm guessing the problem is that the tasks themselves are dependent on :environment and therefore Mongoid (nor the rest of the environment) is loaded.

Another question is how does it even get past the PadrinoTasks.load? call in padrino-tasks/mongoid.rb:2?

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Mar 17, 2013

Member

@skade @DAddYE @dariocravero any thoughts on this?

Member

nesquena commented Mar 17, 2013

@skade @DAddYE @dariocravero any thoughts on this?

@DAddYE

This comment has been minimized.

Show comment
Hide comment
@DAddYE

DAddYE Mar 17, 2013

Member

Yep, I'll take care of it after caching issue

Member

DAddYE commented Mar 17, 2013

Yep, I'll take care of it after caching issue

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Mar 17, 2013

Member

Thanks!

Member

nesquena commented Mar 17, 2013

Thanks!

@skade

This comment has been minimized.

Show comment
Hide comment
@skade

skade Mar 17, 2013

Member

The problem is that all tasks now lazy load the environment. Sadly, the mongoid tasks do this on load:

    if Mongoid::VERSION =~ /^[012]\./

So, yes, the mongoid tasks need to load mongoid and the environment is not loaded.

Member

skade commented Mar 17, 2013

The problem is that all tasks now lazy load the environment. Sadly, the mongoid tasks do this on load:

    if Mongoid::VERSION =~ /^[012]\./

So, yes, the mongoid tasks need to load mongoid and the environment is not loaded.

@skade skade closed this in 4e4ecf8 Mar 17, 2013

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Mar 17, 2013

Member

I see, makes sense. Thanks for fixing.

Member

nesquena commented Mar 17, 2013

I see, makes sense. Thanks for fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment