Recipe Attributes

Recipes may be annotated with attributes that change their behavior.

NameDescription
[no-cd]Don’t change directory before executing recipe.
[no-exit-message]Don’t print an error message if recipe fails.
[linux]Enable recipe on Linux.
[macos]Enable recipe on MacOS.
[unix]Enable recipe on Unixes.
[windows]Enable recipe on Windows.
[private]See Private Recipes.

A recipe can have multiple attributes, either on multiple lines:

[no-cd]
[private]
foo:
    echo "foo"

Or separated by commas on a single line:

[no-cd, private]
foo:
    echo "foo"

Enabling and Disabling Recipes

The [linux], [macos], [unix], and [windows] attributes are configuration attributes. By default, recipes are always enabled. A recipe with one or more configuration attributes will only be enabled when one or more of those configurations is active.

This can be used to write justfiles that behave differently depending on which operating system they run on. The run recipe in this justfile will compile and run main.c, using a different C compiler and using the correct output binary name for that compiler depending on the operating system:

[unix]
run:
  cc main.c
  ./a.out

[windows]
run:
  cl main.c
  main.exe

Disabling Changing Directory1.9.0

just normally executes recipes with the current directory set to the directory that contains the justfile. This can be disabled using the [no-cd] attribute. This can be used to create recipes which use paths relative to the invocation directory, or which operate on the current directory.

For example, this commit recipe:

[no-cd]
commit file:
  git add {{file}}
  git commit

Can be used with paths that are relative to the current directory, because [no-cd] prevents just from changing the current directory when executing commit.