← 返回命令列表

Linux command

rake 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

List all available tasks

rake -T

Run the default task

rake

Run a specific task

rake [task_name]

Run a task in a namespace

rake [namespace]:[task_name]

Run multiple tasks

rake [task1] [task2]

Run a task with arguments

rake [task_name][[arg1],[arg2]]

Run with verbose output

rake --trace [task_name]

Run tasks in parallel

rake -m [task_name]

说明

rake is Ruby's make-like build utility. It executes tasks defined in a Rakefile using standard Ruby syntax, eliminating the need for specialized Makefile syntax or XML configuration. Tasks are defined with dependencies, and Rake automatically determines the correct execution order. The tool supports namespacing for organizing related tasks, file tasks that track modification times, and parallel execution for improved performance. Rake is included in Ruby's standard library since version 1.9 and is widely used in Ruby projects, especially Rails applications where it handles database migrations, asset compilation, and other development tasks.

参数

-T, --tasks _pattern_
Display available tasks with descriptions, optionally filtered by pattern
-f, --rakefile _FILE_
Use specified file as the Rakefile
-t, --trace
Turn on invoke/execute tracing and enable full backtrace
-v, --verbose
Log messages to standard output
-q, --quiet
Do not log messages to standard output
-m, --multitask
Treat all tasks as multitasks (parallel execution)
-j, --jobs _NUM_
Maximum number of parallel tasks (default: CPU cores + 4)
-B, --build-all
Build all prerequisites, including those up-to-date
-n, --dry-run
Do a dry run without executing actions
-N, --no-search
Do not search parent directories for the Rakefile
-P, --prereqs
Display tasks and their prerequisites
-D, --describe _pattern_
Describe tasks (show full descriptions)
-W, --where _pattern_
Show where tasks are defined
-h, --help
Display help message

FAQ

What is the rake command used for?

rake is Ruby's make-like build utility. It executes tasks defined in a Rakefile using standard Ruby syntax, eliminating the need for specialized Makefile syntax or XML configuration. Tasks are defined with dependencies, and Rake automatically determines the correct execution order. The tool supports namespacing for organizing related tasks, file tasks that track modification times, and parallel execution for improved performance. Rake is included in Ruby's standard library since version 1.9 and is widely used in Ruby projects, especially Rails applications where it handles database migrations, asset compilation, and other development tasks.

How do I run a basic rake example?

Run `rake -T` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -T, --tasks _pattern_ do in rake?

Display available tasks with descriptions, optionally filtered by pattern