The puts "I'm in setup" not part of any task - it will be executed regardless of the task you set, even nonexistent, because the file is processed (strictly speaking, when Ruby does not analyze the file, but how it is executed and configures rake tasks):
$ rake foo I'm in setup rake aborted! Don't know how to build task 'foo' (See full trace by running task with --trace)
Only after the file has been read does the task search, and this is what this quote refers to.
If you need common code for all namespace tasks, you will need to create a task for it and do all the other tasks in the namespace, for example:
namespace :setup do task :create => :default do puts "I'm in create" end task :default do puts "I'm in setup" end end
source share