Run
rake
Run the default task
rake <task> <task>
Run several tasks in order
rake <ns>:<task>
Run a namespaced task
rake -n <task>
Dry run: print tasks without executing
rake -j <N>
Run up to N tasks concurrently
Only tasks that are independent run in parallel; multitask and
-m force it.
rake -m
Treat all tasks as multitasks
rake -f <file>
Use another Rakefile
rake -N
Do not search parent directories
rake -R <dir>
Auto-load .rake files from dir
Default is rakelib/.
rake -g
Use system-wide rakefiles only
rake <NAME>=<value>
Set an ENV variable for the run
bundle exec rake <task>
Run with the bundled gem versions
Debug and output
rake -t
Trace invoke and execute, with backtraces
rake --backtrace
Show full backtraces on errors
rake --suppress-backtrace <regex>
Hide matching backtrace lines
rake --job-stats
Show job statistics after the run
rake -v
Echo shell commands run by FileUtils
rake -q
Do not echo FileUtils commands
rake -s
Quiet, and no in directory message
rake -X
Hide deprecation warnings
rake -r <lib>
Require a library before the Rakefile
rake -I <dir>
Add dir to the require path
rake -e '<ruby>'
Run Ruby code and exit
rake -p '<ruby>'
Run Ruby code, print result, exit
rake -E '<ruby>'
Run Ruby code, then continue
Define tasks
task :<name> do ... end
Define a task
task <name>: %w[<a> <b>]
Task with prerequisites
task default: :<name>
Set the default task
desc '<text>'
Describe the next task for -T
namespace :<ns> do ... end
Group tasks under a prefix
task :<name>, [:<a>, :<b>] do |t,
args|
Task with named arguments
args.with_defaults(<a>: <v>)
Default values for arguments
args.extras
Positional args beyond the declared ones
task :<name> => :environment
Load Rails app first (Rails)
Rake::Task[:<name>].invoke
Call a task once from Ruby
Skipped if it already ran in this process.
Rake::Task[:<name>].reenable
Allow a task to run again
Rake::Task[:<name>].execute
Run a task's actions, ignoring prerequisites
Rake::Task[:<name>].clear
Remove actions and prerequisites
task :<name>, [:<a>] => [:<pre>]
Arguments plus prerequisites
^<task> / rake:<task>
Parent / top-level lookup inside a namespace
import '<file>'
Load a file after the Rakefile
multitask :<name> => %w[<a> <b>]
Run prerequisites in parallel
Files and helpers
file '<out>' => %w[<src>] do
|t|
Rebuild when a source is newer
directory '<path>'
Create a directory (and parents) on demand
rule '.o' => '.c' do |t|
Pattern rule for generated files
t.name / t.source
Target name / rule source in a block
t.prerequisites
Prerequisite names in a block
FileList['<glob>']
Lazy list of files by glob
FileList[...].ext('<.o>')
Change extensions
FileList[...].exclude('<glob>')
Drop matching files
sh '<cmd>'
Run a shell command, fail the task on error
sh '<cmd>', verbose: false
Run quietly
ruby '<file.rb>'
Run a Ruby script with the current Ruby
cp / mv / rm_rf / mkdir_p
FileUtils helpers available in tasks
require 'rake/clean'
Add clean and clobber tasks
CLEAN.include('<glob>')
Files removed by rake clean
CLOBBER.include('<glob>')
Files removed by rake clobber
Rake::TestTask.new do |t| ... end
Define a test task
rake <task>[<a>,<b>]
Pass arguments on the command line
rake 'name[a b,c]'
Quote arguments that contain spaces