I'm trying to run an example task that I wrote.
I've placed the file that contains the code under lib/tasks and named it test.rake.
The task code is:
Task :sayHello do
puts "Hello World"
end
When I'm trying to run it I get the following error:
/lib/tasks/test.rake:2:in `<top (required)>': undefined method `Task' for main:Object (NoMethodError)
from -e:1:in `load'
from -e:1:in `<main>'
I've tried to run "tools-> Run Rake Task" but I can't find my task within the given tasks. In addition, when I invoke rake -T from the console, my task is not listed.
I googled this error but all the related errors I see occurred in rake 0.9.0.0 and not in 0.9.2.2
I tried to put in inside a namespace and that causes the following error:
undefined method `namespace' for main:Object
What am I doing wrong here?
It's task (i.e. a method), not Task (i.e. a class). You have to define your task like
task :sayHello do
puts "Hello World"
end
This matters because Ruby is always case sensitive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With