rubyist / guard-rake

guard-rake runs a rake task when files change
MIT License
94 stars 32 forks source link

undefined method `new' for Guard::Rake:Module when I run "guard start" #1

Closed dougireton closed 12 years ago

dougireton commented 12 years ago

I have installed guard-rake using bundler and I've created a guard file to run rake, but when I run "guard start" I get this error:

ERROR: Invalid Guardfile, original error is:
undefined method `new' for Guard::Rake:Module

Any ideas?

dougireton commented 12 years ago

Here's the output of the bundle command:

Using rake (0.9.2) 
Using rb-appscript (0.6.1) 
Using growl_notify (0.0.1) 
Using thor (0.14.6) 
Using guard (0.7.0) 
Using guard-rake (0.0.1) 
Using rb-fsevent (0.4.3.1) 
Using bundler (1.0.18)
rubyist commented 12 years ago

What version of ruby are you using?

lukaszkorecki commented 12 years ago

Hi

I had the same issue, but because I had to get stuff done, I just fixed it in my fork by renaming the guard-rake class. I didn't have time to properly dig in and fix this issue, but from the looks of things it's a naming conflict. One thing to keep in mind that in my fork you define new task with:

guard 'raketask', :task => 'doit' do
  watch(%r{^some_files/.+$})
end

not with guard 'rake', :task => ...

Looking at the code now, it might be as easy as removing the include from here and calling Rake's methods explicitly.

rubyist commented 12 years ago

@dougireton Does using lukaszkorecki's fork fix the problem for you? I've been unable to reproduce, but if his fork works for you I'll be happy to merge the changes in.

dougireton commented 12 years ago

Scott,

I'm at work now, but I can try his fork tonight.

Thanks,

Doug Ireton

On Mon, Sep 26, 2011 at 8:56 AM, Scott Barron < reply@reply.github.com>wrote:

@dougireton Does using lukaszkorecki's fork fix the problem for you? I've been unable to reproduce, but if his fork works for you I'll be happy to merge the changes in.

Reply to this email directly or view it on GitHub: https://github.com/rubyist/guard-rake/issues/1#issuecomment-2199805

dougireton commented 12 years ago

I'm running ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]

dougireton commented 12 years ago

I tried @lukaszkorecki's fork. I get further. When I run guard start I get this:

Guard is now watching at '/Users/doug/src/ruby_koans'
Starting guard-rake walk_the_path

But after the rake task runs once, I get this error:

ERROR: Guard::Raketask failed to achieve its <run_all>, exception was:
Errno::ENOENT: No such file or directory - koans
/Users/doug/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/fileutils.rb:121:in `chdir'
/Users/doug/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/fileutils.rb:121:in `cd'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/rake-0.9.2/lib/rake/file_utils_ext.rb:36:in `cd'
Rakefile:85:in `block in <top (required)>'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/guard-rake-0.0.1/lib/guard/raketask.rb:41:in `run_rake_task'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/guard-rake-0.0.1/lib/guard/raketask.rb:31:in `run_all'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/guard-0.7.0/lib/guard.rb:106:in `supervised_task'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/guard-0.7.0/lib/guard.rb:63:in `block (2 levels) in run_all'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/guard-0.7.0/lib/guard.rb:63:in `each'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/guard-0.7.0/lib/guard.rb:63:in `block in run_all'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/guard-0.7.0/lib/guard.rb:95:in `run'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/guard-0.7.0/lib/guard.rb:62:in `run_all'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/guard-0.7.0/lib/guard/interactor.rb:24:in `block (2 levels) in start'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/guard-0.7.0/lib/guard/interactor.rb:13:in `loop'
/Users/doug/.rvm/gems/ruby-1.9.2-p290@koans/gems/guard-0.7.0/lib/guard/interactor.rb:13:in `block in start'

Guard::Raketask has just been fired

Here is my Guardfile:

guard 'raketask', :task => :walk_the_path do
  watch(%r{~/src/ruby-koans/koans/.+$})
end
lukaszkorecki commented 12 years ago

@dougireton - there's an error in your Guardfile,

it should be placed in ruby_koans directory (using Guard from your home dir isn't recommended), and should look like this:

guard 'raketask', :task => 'walk_the_path' do
  watch(%r{ koans/.*\.rb$ } )
end

(tested with ruby-1.9.2-p290 and ruby-1.8.7-p320.

wkrsz commented 12 years ago

Same issue here:

/Users/wojtek/.rvm/gems/ruby-1.8.7-p352/gems/guard-0.8.8/lib/guard.rb:42:in `initialize_template': undefined method `init' for Guard::Rake:Module (NoMethodError)
    from /Users/wojtek/.rvm/gems/ruby-1.8.7-p352/gems/guard-0.8.8/lib/guard/cli.rb:103:in `init'
    from /Users/wojtek/.rvm/gems/ruby-1.8.7-p352/gems/thor-0.14.6/lib/thor/task.rb:22:in `send'
    from /Users/wojtek/.rvm/gems/ruby-1.8.7-p352/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
    from /Users/wojtek/.rvm/gems/ruby-1.8.7-p352/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
    from /Users/wojtek/.rvm/gems/ruby-1.8.7-p352/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
    from /Users/wojtek/.rvm/gems/ruby-1.8.7-p352/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
    from /Users/wojtek/.rvm/gems/ruby-1.8.7-p352/gems/guard-0.8.8/bin/guard:6
    from /Users/wojtek/.rvm/gems/ruby-1.8.7-p352/bin/guard:19:in `load'
    from /Users/wojtek/.rvm/gems/ruby-1.8.7-p352/bin/guard:19

Wojteks-MacBook-Pro:geepivo wojtek$ bundle exec guard start
ERROR: Invalid Guardfile, original error is:
undefined method `new' for Guard::Rake:Module

@lukaszkorecki, your fork did not resolve the issue for me.

wkrsz commented 12 years ago

I narrowed the issue down to lib/guard/version.rb which defines Guard::Rake as a Module (which interferes with Guard::Rake class definition). Removing the file fixed the errors for me.

rubyist commented 12 years ago

Fix merged in, thanks!

wkrsz commented 12 years ago

Cool.

Thanks for the gem!

On Mon, Nov 7, 2011 at 3:14 PM, Scott Barron < reply@reply.github.com>wrote:

Fix merged in, thanks!


Reply to this email directly or view it on GitHub: https://github.com/rubyist/guard-rake/issues/1#issuecomment-2653883

hojberg commented 12 years ago

Could you publish a new gem version? The current gem is broken because of this!

rubyist commented 12 years ago

Sorry about that, new gem published.

hojberg commented 12 years ago

@rubyist thanks, but the new version you submitted doesn't have the patch applied that renames to RakeVersion :(

rubyist commented 12 years ago

Oh, that's because I'm so awesome I push gems from a stale repository. Next time, I'll have coffee first.

hojberg commented 12 years ago

haha thanks! :)