Rake not executing some tasks, gives "Invoke <task>s (first_time, not_needed)"
I posted a SO question about his issue here. Most of the background is there. Here's the gist:
I have a task called :run that takes one argument, :filter. Depending on what I pass as the argument, it will sometimes execute with the trace:
** Invoke run (first_time)
** Execute run
Other times it doesn't execute at all, giving the trace:
** Invoke runs (first_time, not_needed)
Notice that when it fails, the trace says runs and not run even though run is the task typed in the command.
This happens when I run the rakefile in some directories, but not others.
Using:
- ruby 2.0.0p645 (2015-04-13) [i386-mingw32]
- rake, version 10.4.2
- Window 7
I need more of your Rakefile to reproduce. Except for the missing definition of a run method I can't see the behavior you describe:
$ cat t.rake
desc "Run instances in the runs directory"
task :run, [:filter] do |t, args|
args.with_defaults(:filter => "*")
runs = Dir["runs/"+args.filter]
puts "Running " + runs.length.to_s + " instances..."
for run_path in runs
run(run_path)
end
end
$ rake -t -f t.rake run
** Invoke run (first_time)
** Execute run
Running 0 instances...
$ rake -t -f t.rake run['*']
** Invoke run (first_time)
** Execute run
Running 0 instances...
$ rake -t -f t.rake run['nothing']
** Invoke run (first_time)
** Execute run
Running 0 instances...
$ touch runs/real-file-name
$ rake -t -f t.rake run['*real-file-name*']
** Invoke run (first_time)
** Execute run
Running 1 instances...
rake aborted!
NoMethodError: undefined method `run' for main:Object
/Users/erichodel/tmp/t.rake:7:in `block (2 levels) in <top (required)>'
/Users/erichodel/tmp/t.rake:6:in `each'
/Users/erichodel/tmp/t.rake:6:in `block in <top (required)>'
/usr/local/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/usr/local/bin/rake:33:in `<main>'
Tasks: TOP => run
$ rake -t -f t.rake run['TEST']
** Invoke run (first_time)
** Execute run
Running 0 instances…
$
That's all I need in my rakefile to cause the problem on my machine. As I mentioned, I am having a difficult time reproducing this problem in other directories. Is it possible that rake is searching other paths for tasks and finding something called "runs"?
Is there a way to debug what's happening beyond --trace?
Not able to reproduce the issue on my machine.
@nealkruis When you say in stack overflow post
I noticed that this happens when I run the rakefile in some directories, but not others.
what are the exact directories in which you can reproduce the issue?
@grzuy this is pretty old, but I'll try to recall. The full path to the rakefile directory was:
C:\Users\Neal Kruis\projects\specific-study\analysis
I wonder if the space in the great-grandparent directory would have an impact? That doesn't seem possible since I am only using relative paths for globbing.