LinuxCommandLibrary

rake

Execute tasks defined in a Rakefile

TLDR

Run the default Rakefile task

$ rake
copy

Run a specific task
$ rake [task]
copy

Execute n jobs at a time in parallel (number of CPU cores + 4 by default)
$ rake --jobs [n]
copy

Use a specific Rakefile
$ rake --rakefile [path/to/Rakefile]
copy

Execute rake from another directory
$ rake --directory [path/to/directory]
copy

SYNOPSIS

rake [options] [task] [arguments...]

PARAMETERS

-T, --tasks [PATTERN]
    Display the tasks (matching PATTERN if provided) with their descriptions.

-D, --describe [PATTERN]
    Display the tasks (matching PATTERN if provided) and their descriptions, even if they don't have descriptions.

-P, --prereqs
    Display the tasks and their prerequisites.

-t, --trace
    Enable full backtrace on errors and verbose output for debugging.

-f, --rakefile FILE
    Use the specified Rakefile instead of the default Rakefile or rakefile.

-C, --rakelib DIR
    Add DIR to the Rake library search path. Can be specified multiple times.

-r, --require FILE
    Require a Ruby file before executing the Rakefile.

-s, --silent
    Suppress all Rake messages (e.g., 'executing task...').

-v, --verbose
    Log message to standard output (verbose mode).

-V, --version
    Display the Rake version and exit.

-h, --help
    Display a help message and exit.

DESCRIPTION

Rake (Ruby Make) is a software task management and build automation tool written in Ruby. It's conceptually similar to the classic Unix make utility but leverages the full power and flexibility of the Ruby programming language.

Rake allows developers to define a set of tasks and their dependencies within a file typically named Rakefile. These tasks can be anything from compiling code, running tests, deploying applications, or cleaning up build artifacts. Because Rakefiles are pure Ruby code, they can execute any Ruby method or shell command, making them incredibly versatile for automating complex workflows.

It is widely used in the Ruby ecosystem, especially within Ruby on Rails projects, where it handles database migrations, asset precompilation, and many other common development and deployment tasks. Rake provides a clean, programmatic way to manage project-specific operations, offering a more expressive alternative to shell scripts for many build and automation needs.

CAVEATS

Rake is written in Ruby and requires a Ruby environment to be installed and configured on your system. Its tasks are defined in Rakefiles which are Ruby scripts, meaning knowledge of Ruby is beneficial for defining or modifying tasks. While it runs on Linux, it's not a core system utility but rather an application commonly used in Ruby development.

RAKEFILES

Rake tasks are defined in a file named Rakefile (or rakefile), located in the project's root directory. This file is essentially a Ruby script that uses Rake's DSL (Domain Specific Language) to define tasks, their dependencies, and the actions to be performed. Each task typically has a name and a block of Ruby code that gets executed when the task is invoked. For example, a task might run tests or compile assets.

TASKS

A Rake task is a named operation that can be executed. Tasks can have prerequisites, meaning other tasks that must be completed before the current task can run. This dependency mechanism allows for complex workflows to be defined and managed. Tasks can also accept arguments, providing flexibility in their execution. To run a task, you simply type rake [task_name] in your terminal from the project's root directory.

HISTORY

Rake was created by Jim Weirich, a prominent figure in the Ruby community, in 2003. It quickly became the standard build tool for Ruby projects, largely replacing shell scripts for complex build and automation tasks. Its integration with the Ruby on Rails framework solidified its widespread adoption, making it an indispensable tool for managing development and deployment workflows in the Ruby ecosystem.

SEE ALSO

make(1), bundle(1), ruby(1)

Copied to clipboard