Skip to content
Back to search

just

🤖 Just a command runner

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/casey/just with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/casey/just'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/casey--just/badge.svg)](/listings/casey--just)

HTML

<a href="/listings/casey--just"><img src="/api/listings/casey--just/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Just can be installed using your favorite [package manager](#packages), by downloading [pre-built binaries](#pre-built-binaries), or building from source with `cargo install just`.

Prerequisites

`just` should run on any system with a reasonable `sh`, including Linux, macOS, and the BSDs.

Windows

On Windows, `just` works with the `sh` provided by [Git for Windows](https://git-scm.com), [GitHub Desktop](https://desktop.github.com), or [Cygwin](http://www.cygwin.com). After installation, `sh` must be available in the `PATH` of the shell you want to invoke `just` from.

If you'd rather not install `sh`, you can use the `shell` setting to use the shell of your choice.

Like PowerShell:

# use PowerShell instead of sh:
set shell := ["powershell.exe", "-c"]

hello:
  Write-Host "Hello, world!"

…or `cmd.exe`:

# use cmd.exe instead of sh:
set shell := ["cmd.exe", "/c"]

list:
  dir

You can also set the shell using command-line arguments. For example, to use PowerShell, launch `just` with `--shell powershell.exe --shell-arg -c`.

(PowerShell is installed by default on Windows 7 SP1 and Windows Server 2008 R2 SP1 and later, and `cmd.exe` is quite fiddly, so PowerShell is recommended for most Windows users.)

Packages

Cross-platform

<table> <thead> <tr> <th>Package Manager</th> <th>Package</th> <th>Command</th> </tr> </thead> <tbody> <tr> <td><a href=https://github.com/alexellis/arkade>arkade</a></td> <td>just</td> <td><code>arkade get just</code></td> </tr> <tr> <td><a href=https://asdf-vm.com>asdf</a></td> <td><a href=https://github.com/olofvndrhr/asdf-just>just</a></td> <td> <code>asdf plugin add just</code><br> <code>asdf install just &lt;version&gt;</code> </td> </tr> <tr> <td><a href=https://www.rust-lang.org>Cargo</a></td> <td><a href=https://crates.io/crates/just>just</a></td> <td><code>cargo install just</code></td> </tr> <tr> <td><a href=https://github.com/cargo-bins/cargo-binstall>Cargo Binstall</a></td> <td><a href=https://crates.io/crates/just>just</a></td> <td><code>cargo binstall just</code></td> </tr> <tr> <td><a href=https://docs.conda.io/projects/conda/en/latest/index.html>Conda</a></td> <td><a href=https://anaconda.org/conda-forge/just>just</a></td> <td><code>conda install -c conda-forge just</code></td> </tr> <tr> <td><a href=https://brew.sh>Homebrew</a></td> <td><a href=https://formulae.brew.sh/formula/just>just</a></td> <td><code>brew install just</code></td> </tr> <tr> <td><a href=https://nixos.org/nix/>Nix</a></td> <td><a href=https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/ju/just/package.nix>just</a></td> <td><code>nix-env -iA nixpkgs.just</code></td> </tr> <tr> <td><a href=https://www.npmjs.com/>npm</a></td> <td><a href=https://www.npmjs.com/package/rust-just>rust-just</a></td> <td><code>npm install -g rust-just</code></td> </tr> <tr> <td><a href=https://pipx.pypa.io/stable/>pipx</a></td> <td><a href=https://pypi.org/project/rust-just/>rust-just</a></td> <td><code>pipx install rust-just</code></td> </tr> <tr> <td><a href=https://snapcraft.io>Snap</a></td> <td><a href=https://snapcraft.io/just>just</a></td> <td><code>snap install --edge --classic just</code></td> </tr> <tr> <td><a href=https://spack.io/>Spack</a></td> <td><a href=https://packages.spack.io/package.html?name=just>just</a></td> <td><code>spack install just</code></td> </tr> <tr> <td><a href=https://docs.astral.sh/uv/>uv</a></td> <td><a href=https://pypi.org/project/rust-just/>rust-just</a></td> <td><code>uv tool install rust-just</code></td> </tr> </tbody> </table>

BSD

<table> <thead> <tr>

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 6,061 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. <div align=right>Table of Contents↗️</div>
  2. <h1 align=center><code>just</code></h1>
  3. <div align=center>
  4. <a href=https://crates.io/crates/just>
  5. <img src=https://img.shields.io/crates/v/just.svg alt="crates.io version">
  6. </a>
  7. <a href=https://github.com/casey/just/actions/workflows/ci.yaml>
  8. <img src=https://github.com/casey/just/actions/workflows/ci.yaml/badge.svg alt="build status">
  9. </a>
  10. <a href=https://github.com/casey/just/releases>
  11. <img src=https://img.shields.io/github/downloads/casey/just/total.svg alt=downloads>
  12. </a>
  13. <a href=https://discord.gg/ezYScXR>
  14. <img src=https://img.shields.io/discord/695580069837406228?logo=discord alt="chat on discord">
  15. </a>
  16. <a href=mailto:casey@rodarmor.com?subject=Thanks%20for%20Just!>
  17. <img src=https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg alt="say thanks">
  18. </a>
  19. </div>
  20. <br>
  21. `just` is a handy way to save and run project-specific commands.
  22. This readme is also available as a [book](https://just.systems/man/en/). The
  23. book reflects the latest release, whereas the
  24. [readme on GitHub](https://github.com/casey/just/blob/master/README.md)
  25. reflects latest master.
  26. (中文文档在 [这里](https://github.com/casey/just/blob/master/README.中文.md),
  27. 快看过来!)
  28. Commands, called recipes, are stored in a file called `justfile` with syntax
  29. inspired by `make`:
  30. ![screenshot](https://raw.githubusercontent.com/casey/just/master/etc/screenshot.png)
  31. You can then run them with `just RECIPE`:
  32. ```console
  33. $ just test-all
  34. cc *.c -o main
  35. ./test --all
  36. Yay, all your tests passed!
  37. ```
  38. `just` has a ton of useful features, and many improvements over `make`:
  39. - `just` is a command runner, not a build system, so it avoids much of
  40. [`make`'s complexity and idiosyncrasies](#what-are-the-idiosyncrasies-of-make-that-just-avoids).
  41. No need for `.PHONY` recipes!
  42. - Linux, macOS, Windows, and other reasonable unixes are supported with no
  43. additional dependencies. (Although if your system doesn't have an `sh`,
  44. you'll need to [choose a different shell](#shell).)
  45. - Errors are specific and informative, and syntax errors are reported along
  46. with their source context.
  47. - Recipes can accept [command line arguments](#recipe-parameters), including
  48. [flags and options](#recipe-flags-and-options).
  49. - `just` has a rich [expression language](#expressions) and many
  50. built-in-functions.
  51. - Wherever possible, errors are resolved statically. Unknown recipes and
  52. circular dependencies are reported before anything runs.
  53. - `just` [loads `.env` files](#dotenv-settings), making it easy to populate
  54. environment variables.
  55. - Recipes can be [listed from the command line](#listing-available-recipes).
  56. - Command line completion scripts are
  57. [available for most popular shells](#shell-completion-scripts).
  58. - Recipes can be written in
  59. [arbitrary languages](#shebang-recipes), like Python or Node.js.
  60. - `just` can be invoked from any subdirectory, not just the directory that
  61. contains the `justfile`.
  62. - `justfiles` can be organized into multiple files using [modules](#modules)
  63. and [imports](#imports).
  64. - And [much more](https://just.systems/man/en/)!
  65. If you need help with `just`, please feel free to open an issue or ping me on
  66. [Discord](https://discord.gg/ezYScXR). Feature requests and bug reports are
  67. always welcome!
  68. Installation
  69. ------------
  70. Just can be installed using your favorite [package manager](#packages), by
  71. downloading [pre-built binaries](#pre-built-binaries), or building from source
  72. with `cargo install just`.
  73. ### Prerequisites
  74. `just` should run on any system with a reasonable `sh`, including Linux, macOS,
  75. and the BSDs.
  76. #### Windows
  77. On Windows, `just` works with the `sh` provided by
  78. [Git for Windows](https://git-scm.com),
  79. [GitHub Desktop](https://desktop.github.com), or
  80. [Cygwin](http://www.cygwin.com). After installation, `sh` must be available in
  81. the `PATH` of the shell you want to invoke `just` from.
  82. If you'd rather not install `sh`, you can use the `shell` setting to use the
  83. shell of your choice.
  84. Like PowerShell:
  85. ```just
  86. # use PowerShell instead of sh:
  87. set shell := ["powershell.exe", "-c"]
  88. hello:
  89. Write-Host "Hello, world!"
  90. ```
  91. …or `cmd.exe`:
  92. ```just
  93. # use cmd.exe instead of sh:
  94. set shell := ["cmd.exe", "/c"]
  95. list:
  96. dir
  97. ```
  98. You can also set the shell using command-line arguments. For example, to use
  99. PowerShell, launch `just` with `--shell powershell.exe --shell-arg -c`.
  100. (PowerShell is installed by default on Windows 7 SP1 and Windows Server 2008 R2
  101. SP1 and later, and `cmd.exe` is quite fiddly, so PowerShell is recommended for
  102. most Windows users.)
  103. ### Packages
  104. #### Cross-platform
  105. <table>
  106. <thead>
  107. <tr>
  108. <th>Package Manager</th>
  109. <th>Package</th>
  110. <th>Command</th>
  111. </tr>
  112. </thead>
  113. <tbody>
  114. <tr>
  115. <td><a href=https://github.com/alexellis/arkade>arkade</a></td>
  116. <td>just</td>
  117. <td><code>arkade get just</code></td>
  118. </tr>
  119. <tr>
  120. <td><a href=https://asdf-vm.com>asdf</a></td>
  121. <td><a href=https://github.com/olofvndrhr/asdf-just>just</a></td>
  122. <td>
  123. <code>asdf plugin add just</code><br>
  124. <code>asdf install just &lt;version&gt;</code>
  125. </td>
  126. </tr>
  127. <tr>
  128. <td><a href=https://www.rust-lang.org>Cargo</a></td>
  129. <td><a href=https://crates.io/crates/just>just</a></td>
  130. <td><code>cargo install just</code></td>
  131. </tr>
  132. <tr>
  133. <td><a href=https://github.com/cargo-bins/cargo-binstall>Cargo Binstall</a></td>
  134. <td><a href=https://crates.io/crates/just>just</a></td>
  135. <td><code>cargo binstall just</code></td>
  136. </tr>
  137. <tr>
  138. <td><a href=https://docs.conda.io/projects/conda/en/latest/index.html>Conda</a></td>
  139. <td><a href=https://anaconda.org/conda-forge/just>just</a></td>
  140. <td><code>conda install -c conda-forge just</code></td>
  141. </tr>
  142. <tr>
  143. <td><a href=https://brew.sh>Homebrew</a></td>
  144. <td><a href=https://formulae.brew.sh/formula/just>just</a></td>
  145. <td><code>brew install just</code></td>
  146. </tr>
  147. <tr>
  148. <td><a href=https://nixos.org/nix/>Nix</a></td>
  149. <td><a href=https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/ju/just/package.nix>just</a></td>
  150. <td><code>nix-env -iA nixpkgs.just</code></td>
  151. </tr>
  152. <tr>
  153. <td><a href=https://www.npmjs.com/>npm</a></td>
  154. <td><a href=https://www.npmjs.com/package/rust-just>rust-just</a></td>
  155. <td><code>npm install -g rust-just</code></td>
  156. </tr>
  157. <tr>
  158. <td><a href=https://pipx.pypa.io/stable/>pipx</a></td>
  159. <td><a href=https://pypi.org/project/rust-just/>rust-just</a></td>
  160. <td><code>pipx install rust-just</code></td>
  161. </tr>
  162. <tr>
  163. <td><a href=https://snapcraft.io>Snap</a></td>
  164. <td><a href=https://snapcraft.io/just>just</a></td>
  165. <td><code>snap install --edge --classic just</code></td>
  166. </tr>
  167. <tr>
  168. <td><a href=https://spack.io/>Spack</a></td>
  169. <td><a href=https://packages.spack.io/package.html?name=just>just</a></td>
  170. <td><code>spack install just</code></td>
  171. </tr>
  172. <tr>
  173. <td><a href=https://docs.astral.sh/uv/>uv</a></td>
  174. <td><a href=https://pypi.org/project/rust-just/>rust-just</a></td>
  175. <td><code>uv tool install rust-just</code></td>
  176. </tr>
  177. </tbody>
  178. </table>
  179. #### BSD
  180. <table>
  181. <thead>
  182. <tr>
  183. <th>Operating System</th>
  184. <th>Package Manager</th>
  185. <th>Package</th>
  186. <th>Command</th>
  187. </tr>
  188. </thead>
  189. <tbody>
  190. <tr>
  191. <td><a href=https://www.freebsd.org>FreeBSD</a></td>
  192. <td><a href=https://www.freebsd.org/doc/handbook/pkgng-intro.html>pkg</a></td>
  193. <td><a href=https://www.freshports.org/deskutils/just/>just</a></td>
  194. <td><code>pkg install just</code></td>
  195. </tr>
  196. <tr>
  197. <td><a href=https://www.openbsd.org>OpenBSD</a></td>
  198. <td><a href=https://www.openbsd.org/faq/faq15.html>pkg_*</a></td>
  199. <td><a href=https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/sysutils/just>just</a></td>
  200. <td><code>pkg_add just</code></td>
  201. </tr>
  202. </tbody>
  203. </table>
  204. #### Linux
  205. <table>
  206. <thead>
  207. <tr>
  208. <th>Operating System</th>
  209. <th>Package Manager</th>
  210. <th>Package</th>
  211. <th>Command</th>
  212. </tr>
  213. </thead>
  214. <tbody>
  215. <tr>
  216. <td><a href=https://alpinelinux.org>Alpine</a></td>
  217. <td><a href=https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management>apk-tools</a></td>
  218. <td><a href=https://pkgs.alpinelinux.org/package/edge/community/x86_64/just>just</a></td>
  219. <td><code>apk add just</code></td>
  220. </tr>
  221. <tr>
  222. <td><a href=https://www.archlinux.org>Arch</a></td>
  223. <td><a href=https://wiki.archlinux.org/title/Pacman>pacman</a></td>
  224. <td><a href=https://archlinux.org/packages/extra/x86_64/just/>just</a></td>
  225. <td><code>pacman -S just</code></td>
  226. </tr>
  227. <tr>
  228. <td>
  229. <a href=https://debian.org>Debian 13</a> and
  230. <a href=https://ubuntu.com>Ubuntu 24.04</a> derivatives</td>
  231. <td><a href=https://en.wikipedia.org/wiki/APT_(software)>apt</a></td>
  232. <td><a href=https://packages.debian.org/trixie/just>just</a></td>
  233. <td><code>apt install just</code></td>
  234. </tr>
  235. <tr>
  236. <td><a href=https://getfedora.org>Fedora</a></td>
  237. <td><a href=https://dnf.readthedocs.io/en/latest/>DNF</a></td>
  238. <td><a href=https://src.fedoraproject.org/rpms/rust-just>just</a></td>
  239. <td><code>dnf install just</code></td>
  240. </tr>
  241. <tr>
  242. <td><a href=https://www.gentoo.org>Gentoo</a></td>
  243. <td><a href=https://wiki.gentoo.org/wiki/Portage>Portage</a></td>
  244. <td><a href=https://packages.gentoo.org/packages/dev-build/just>dev-build/just</a></td>
  245. <td>
  246. <code>emerge -av dev-build/just</code>
  247. </td>
  248. </tr>
  249. <tr>
  250. <td><a href=https://nixos.org/nixos/>NixOS</a></td>
  251. <td><a href=https://nixos.org/nix/>Nix</a></td>
  252. <td><a href=https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/ju/just/package.nix>just</a></td>
  253. <td><code>nix-env -iA nixos.just</code></td>
  254. </tr>
  255. <tr>
  256. <td><a href=https://opensuse.org>openSUSE</a></td>
  257. <td><a href=https://en.opensuse.org/Portal:Zypper>Zypper</a></td>
  258. <td><a href=https://build.opensuse.org/package/show/Base:System/just>just</a></td>
  259. <td><code>zypper in just</code></td>
  260. </tr>
  261. <tr>
  262. <td><a href=https://getsol.us>Solus</a></td>
  263. <td><a href=https://getsol.us/articles/package-management/basics/en>eopkg</a></td>
  264. <td><a href=https://dev.getsol.us/source/just/>just</a></td>
  265. <td><code>eopkg install just</code></td>
  266. </tr>
  267. <tr>
  268. <td><a href=https://voidlinux.org>Void</a></td>
  269. <td><a href=https://wiki.voidlinux.org/XBPS>XBPS</a></td>
  270. <td><a href=https://github.com/void-linux/void-packages/blob/master/srcpkgs/just/template>just</a></td>
  271. <td><code>xbps-install -S just</code></td>
  272. </tr>
  273. </tbody>
  274. </table>
  275. #### Windows
  276. <table>
  277. <thead>
  278. <tr>
  279. <th>Package Manager</th>
  280. <th>Package</th>
  281. <th>Command</th>
  282. </tr>
  283. </thead>
  284. <tbody>
  285. <tr>
  286. <td><a href=https://chocolatey.org>Chocolatey</a></td>
  287. <td><a href=https://github.com/michidk/just-choco>just</a></td>
  288. <td><code>choco install just</code></td>
  289. </tr>
  290. <tr>
  291. <td><a href=https://scoop.sh>Scoop</a></td>
  292. <td><a href=https://github.com/ScoopInstaller/Main/blob/master/bucket/just.json>just</a></td>
  293. <td><code>scoop install just</code></td>
  294. </tr>
  295. <tr>
  296. <td><a href=https://learn.microsoft.com/en-us/windows/package-manager/>Windows Package Manager</a></td>
  297. <td><a href=https://github.com/microsoft/winget-pkgs/tree/master/manifests/c/Casey/Just>Casey/Just</a></td>
  298. <td><code>winget install --id Casey.Just --exact</code></td>
  299. </tr>
  300. </tbody>
  301. </table>
  302. #### macOS
  303. <table>
  304. <thead>
  305. <tr>
  306. <th>Package Manager</th>
  307. <th>Package</th>
  308. <th>Command</th>
  309. </tr>
  310. </thead>
  311. <tbody>
  312. <tr>
  313. <td><a href=https://www.macports.org>MacPorts</a></td>
  314. <td><a href=https://ports.macports.org/port/just/summary>just</a></td>
  315. <td><code>port install just</code></td>
  316. </tr>
  317. </tbody>
  318. </table>
  319. ![just package version table](https://repology.org/badge/vertical-allrepos/just.svg)
  320. ### Pre-Built Binaries
  321. Pre-built binaries for Linux, macOS, and Windows can be found on
  322. [the releases page](https://github.com/casey/just/releases).
  323. You can use the following command on Linux, macOS, or Windows to download the
  324. latest release, just replace `DEST` with the directory where you'd like to put
  325. `just`:
  326. ```console
  327. curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to DEST
  328. ```
  329. For example, to install `just` to `~/bin`:
  330. ```console
  331. # create ~/bin
  332. mkdir -p ~/bin
  333. # download and extract just to ~/bin/just
  334. curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin
  335. # add `~/bin` to the paths that your shell searches for executables
  336. # this line should be added to your shell's initialization file,
  337. # e.g. `~/.bashrc` or `~/.zshrc`
  338. export PATH="$PATH:$HOME/bin"
  339. # just should now be executable
  340. just --help
  341. ```
  342. Note that `install.sh` may fail on GitHub Actions, or in other environments
  343. where many machines share IP addresses. `install.sh` calls GitHub APIs in order
  344. to determine the latest version of `just` to install, and those API calls are
  345. rate-limited on a per-IP basis. To make `install.sh` more reliable in such
  346. circumstances, pass a specific tag to install with `--tag`.
  347. Another way to avoid rate-limiting is to pass a GitHub authentication token to
  348. `install.sh` as an environment variable named `GITHUB_TOKEN`, allowing it to
  349. authenticate its requests.
  350. [Releases](https://github.com/casey/just/releases) include a `SHA256SUM` file
  351. which can be used to verify the integrity of pre-built binary archives.
  352. To verify a release, download the pre-built binary archive along with the
  353. `SHA256SUM` file and run:
  354. ```sh
  355. shasum --algorithm 256 --ignore-missing --check SHA256SUMS
  356. ```
  357. ### GitHub Actions
  358. `just` can be installed on GitHub Actions in a few ways.
  359. Using package managers pre-installed on GitHub Actions runners on macOS with
  360. `brew install just`, and on Windows with `choco install just`.
  361. With [extractions/setup-just](https://github.com/extractions/setup-just):
  362. ```yaml
  363. - uses: extractions/setup-just@v3
  364. with:
  365. just-version: 1.5.0 # optional semver specification, otherwise latest
  366. ```
  367. Or with [taiki-e/install-action](https://github.com/taiki-e/install-action):
  368. ```yaml
  369. - uses: taiki-e/install-action@just
  370. ```
  371. ### Docker
  372. `just` is available as a Docker image from
  373. [the GitHub Container Registry](https://ghcr.io/casey/just).
  374. To copy `just` into a Docker image, add the following line to your
  375. `Dockerfile`:
  376. ```dockerfile
  377. COPY --from=ghcr.io/casey/just:latest /just /usr/local/bin/
  378. ```
  379. After copying, `just` may also be used as part of a docker build:
  380. ```dockerfile
  381. RUN just
  382. ```
  383. ### Release RSS Feed
  384. An [RSS feed](https://en.wikipedia.org/wiki/RSS) of `just` releases is
  385. available [here](https://github.com/casey/just/releases.atom).
  386. ### Node.js Installation
  387. [just-install](https://npmjs.com/package/just-install) can be used to automate
  388. installation of `just` in Node.js applications.
  389. `just` is a great, more robust alternative to npm scripts. If you want to
  390. include `just` in the dependencies of a Node.js application, `just-install`
  391. will install a local, platform-specific binary as part of the `npm install`
  392. command. This removes the need for every developer to install `just`
  393. independently using one of the processes mentioned above. After installation,
  394. the `just` command will work in npm scripts or with npx. It's great for teams
  395. who want to make the setup process for their project as easy as possible.
  396. For more information, see the
  397. [just-install README file](https://github.com/brombal/just-install#readme).
  398. ### Nix Flake
  399. The `just` repository includes a
  400. [`flake.nix`](https://github.com/casey/just/tree/master/flake.nix) that defines
  401. a [nix flake](https://nix.dev/concepts/flakes.html), allowing you to use `just`
  402. as an input to another flake:
  403. ```nix
  404. {
  405. inputs = {
  406. just.url = "github:casey/just";
  407. }
  408. outputs = {self, nixpkgs, just}: {
  409. }
  410. }
  411. ```
  412. Backwards Compatibility
  413. -----------------------
  414. With the release of version 1.0, `just` features a strong commitment to
  415. backwards compatibility and stability.
  416. Future releases will not introduce backwards incompatible changes that make
  417. existing `justfile`s stop working, or break working invocations of the
  418. command-line interface.
  419. This does not, however, preclude fixing outright bugs, even if doing so might
  420. break `justfiles` that rely on their behavior.
  421. There will never be a `just` 2.0. Any desirable backwards-incompatible changes
  422. will be opt-in on a per-`justfile` basis, so users may migrate at their
  423. leisure.
  424. Features that aren't yet ready for stabilization are marked as unstable and may
  425. be changed or removed at any time. Using unstable features produces an error by
  426. default, which can be suppressed by passing the `--unstable` flag,
  427. `set unstable`, or setting the environment variable `JUST_UNSTABLE` to any
  428. value other than `false`, `0`, or the empty string.
  429. ### Requiring a Minimum Just Version
  430. If you use features of `just` which require a particular version, you may use
  431. the `minimum-version`<sup>1.55.0</sup> setting to make it an error to use older
  432. versions of `just`:
  433. ```justfile
  434. set minimum-version := '1.55.0'
  435. ```
  436. If `just` encounters a minimum version greater than its own version, it will
  437. print an error message with the required version, which is hopefully better
  438. than the confused error message it would have otherwise produced.
  439. The `minimum-version` setting should be placed at the top of the `justfile`,
  440. before any usage of the new feature that it guards.
  441. Any features which change the lexer in forward-incompatible ways will still
  442. produce an unhelpful error message, as the minimum version check is implemented
  443. in the parser, which runs after the lexer.
  444. Editor Support
  445. --------------
  446. `justfile` syntax is close enough to `make` that you may want to tell your
  447. editor to use `make` syntax highlighting for `just`.
  448. ### Vim and Neovim
  449. Vim version 9.1.1042 or better and Neovim version 0.11 or better support
  450. Justfile syntax highlighting out of the box, thanks to
  451. [pbnj](https://github.com/pbnj).
  452. #### `vim-just`
  453. The [vim-just](https://github.com/NoahTheDuke/vim-just) plugin provides syntax
  454. highlighting for `justfile`s.
  455. Install it with your favorite package manager, like
  456. [Plug](https://github.com/junegunn/vim-plug):
  457. ```vim
  458. call plug#begin()
  459. Plug 'NoahTheDuke/vim-just'
  460. call plug#end()
  461. ```
  462. Or with Vim's built-in package support:
  463. ```console
  464. mkdir -p ~/.vim/pack/vendor/start
  465. cd ~/.vim/pack/vendor/start
  466. git clone https://github.com/NoahTheDuke/vim-just.git
  467. ```
  468. #### `tree-sitter-just`
  469. [tree-sitter-just](https://github.com/IndianBoy42/tree-sitter-just) is an
  470. [Nvim Treesitter](https://github.com/nvim-treesitter/nvim-treesitter) plugin
  471. for Neovim.
  472. ### Emacs
  473. [just-mode](https://github.com/leon-barrett/just-mode.el) provides syntax
  474. highlighting and automatic indentation of `justfile`s. It is available on
  475. [MELPA](https://melpa.org/) as [just-mode](https://melpa.org/#/just-mode).
  476. [justl](https://github.com/psibi/justl.el) provides commands for executing and
  477. listing recipes.
  478. You can add the following to an individual `justfile` to enable `make` mode on
  479. a per-file basis:
  480. ```text
  481. # Local Variables:
  482. # mode: makefile
  483. # End:
  484. ```
  485. ### Visual Studio Code
  486. An extension for VS Code is [available here](https://github.com/nefrob/vscode-just).
  487. Unmaintained VS Code extensions include
  488. [skellock/vscode-just](https://github.com/skellock/vscode-just) and
  489. [sclu1034/vscode-just](https://github.com/sclu1034/vscode-just).
  490. ### JetBrains IDEs
  491. A plugin for JetBrains IDEs by [linux_china](https://github.com/linux-china) is
  492. [available here](https://plugins.jetbrains.com/plugin/18658-just).
  493. ### Kakoune
  494. Kakoune supports `justfile` syntax highlighting out of the box, thanks to
  495. TeddyDD.
  496. ### Helix
  497. [Helix](https://helix-editor.com/) supports `justfile` syntax highlighting
  498. out-of-the-box since version 23.05.
  499. ### Sublime Text
  500. The [Just package](https://github.com/nk9/just_sublime) by
  501. [nk9](https://github.com/nk9) with `just` syntax and some other tools is
  502. available on [PackageControl](https://packagecontrol.io/packages/Just).
  503. ### Micro
  504. [Micro](https://micro-editor.github.io/) supports Justfile syntax highlighting
  505. out of the box, thanks to [tomodachi94](https://github.com/tomodachi94).
  506. ### Zed
  507. The [zed-just](https://github.com/jackTabsCode/zed-just/) extension by
  508. [jackTabsCode](https://github.com/jackTabsCode) is available on the
  509. [Zed extensions page](https://zed.dev/extensions?query=just).
  510. ### Other Editors
  511. Feel free to send me the commands necessary to get syntax highlighting working
  512. in your editor of choice so that I may include them here.
  513. ### Language Server Protocol
  514. [just-lsp](https://github.com/terror/just-lsp) provides a [language server
  515. protocol](https://en.wikipedia.org/wiki/Language_Server_Protocol)
  516. implementation, enabling features such as go-to-definition, inline diagnostics,
  517. and code completion.
  518. ### Model Context Protocol
  519. [just-mcp](https://github.com/promptexecution/just-mcp) provides a
  520. [model context protocol](https://en.wikipedia.org/wiki/Model_Context_Protocol)
  521. adapter to allow LLMs to query the contents of `justfiles` and run recipes.
  522. Quick Start
  523. -----------
  524. See the installation section for how to install `just` on your computer. Try
  525. running `just --version` to make sure that it's installed correctly.
  526. For an overview of the syntax, check out
  527. [this cheatsheet](https://cheatography.com/linux-china/cheat-sheets/justfile/).
  528. Once `just` is installed and working, create a file named `justfile` in the
  529. root of your project with the following contents:
  530. ```just
  531. recipe-name:
  532. echo 'This is a recipe!'
  533. # this is a comment
  534. another-recipe:
  535. @echo 'This is another recipe.'
  536. ```
  537. When you invoke `just`, it looks for a file named `justfile` in the current
  538. directory and upwards, so you can invoke it from any subdirectory of your
  539. project.
  540. The search for a `justfile` is case insensitive, so any case, like `Justfile`,
  541. `JUSTFILE`, or `JuStFiLe`, will work. `just` will also look for files with the
  542. name `.justfile`, in case you'd like to hide a `justfile`.
  543. By default, running `just` with no arguments runs the first recipe in the
  544. `justfile`:
  545. ```console
  546. $ just
  547. echo 'This is a recipe!'
  548. This is a recipe!
  549. ```
  550. One or more arguments specify the recipe(s) to run:
  551. ```console
  552. $ just another-recipe
  553. This is another recipe.
  554. ```
  555. `just` prints each command to standard error before running it, which is why
  556. `echo 'This is a recipe!'` was printed. This is suppressed for lines starting
  557. with `@`, which is why `echo 'This is another recipe.'` was not printed.
  558. Recipes stop running if a command fails. Here `cargo publish` will only run if
  559. `cargo test` succeeds:
  560. ```just
  561. publish:
  562. cargo test
  563. # tests passed, time to publish!
  564. cargo publish
  565. ```
  566. Recipes can depend on other recipes. Here the `test` recipe depends on the
  567. `build` recipe, so `build` will run before `test`:
  568. ```just
  569. build:
  570. cc main.c foo.c bar.c -o main
  571. test: build
  572. ./test
  573. sloc:
  574. @echo "`wc -l *.c` lines of code"
  575. ```
  576. ```console
  577. $ just test
  578. cc main.c foo.c bar.c -o main
  579. ./test
  580. testing… all tests passed!
  581. ```
  582. Recipes without dependencies will run in the order they're given on the command
  583. line:
  584. ```console
  585. $ just build sloc
  586. cc main.c foo.c bar.c -o main
  587. 1337 lines of code
  588. ```
  589. Dependencies will always run first, even if they are passed after a recipe that
  590. depends on them:
  591. ```console
  592. $ just test build
  593. cc main.c foo.c bar.c -o main
  594. ./test
  595. testing… all tests passed!
  596. ```
  597. Recipes may depend on recipes in submodules:
  598. ```justfile
  599. mod foo
  600. baz: foo::bar
  601. ```
  602. Examples
  603. --------
  604. A variety of `justfile`s can be found in the
  605. [examples directory](https://github.com/casey/just/tree/master/examples) and on
  606. [GitHub](https://github.com/search?q=path%3A**%2Fjustfile&type=code).
  607. Recipes
  608. -------
  609. ### The Default Recipe
  610. When `just` is invoked without a recipe, it runs the recipe with the
  611. `[default]` attribute, or the first recipe in the `justfile` if no recipe has
  612. the `[default]` attribute.
  613. This recipe might be the most frequently run command in the project, like
  614. running the tests:
  615. ```just
  616. test:
  617. cargo test
  618. ```
  619. You can also use dependencies to run multiple recipes by default:
  620. ```just
  621. default: lint build test
  622. build:
  623. echo Building…
  624. test:
  625. echo Testing…
  626. lint:
  627. echo Linting…
  628. ```
  629. If no recipe makes sense as the default recipe, you can use
  630. `default-list`<sup>1.52.0</sup> to list the available recipes instead:
  631. ```just
  632. set default-list := true
  633. ```
  634. ### Recipe Parameters
  635. Recipes may have parameters. Here recipe `build` has a parameter called
  636. `target`:
  637. ```just
  638. build target:
  639. @echo 'Building {{target}}…'
  640. cd {{target}} && make
  641. ```
  642. To pass arguments on the command line, put them after the recipe name:
  643. ```console
  644. $ just build my-awesome-project
  645. Building my-awesome-project…
  646. cd my-awesome-project && make
  647. ```
  648. To pass arguments to a dependency, put the dependency in parentheses along with
  649. the arguments:
  650. ```just
  651. default: (build "main")
  652. build target:
  653. @echo 'Building {{target}}…'
  654. cd {{target}} && make
  655. ```
  656. Variables can also be passed as arguments to dependencies:
  657. ```just
  658. target := "main"
  659. _build version:
  660. @echo 'Building {{version}}…'
  661. cd {{version}} && make
  662. build: (_build target)
  663. ```
  664. A command's arguments can be passed to a dependency by putting the dependency in
  665. parentheses along with the arguments:
  666. ```just
  667. build target:
  668. @echo "Building {{target}}…"
  669. push target: (build target)
  670. @echo 'Pushing {{target}}…'
  671. ```
  672. Parameters may have default values:
  673. ```just
  674. default := 'all'
  675. test target tests=default:
  676. @echo 'Testing {{target}}:{{tests}}…'
  677. ./test --tests {{tests}} {{target}}
  678. ```
  679. Parameters with default values may be omitted:
  680. ```console
  681. $ just test server
  682. Testing server:all…
  683. ./test --tests all server
  684. ```
  685. Or supplied:
  686. ```console
  687. $ just test server unit
  688. Testing server:unit…
  689. ./test --tests unit server
  690. ```
  691. Default values may be arbitrary expressions, but expressions containing the
  692. `+`, `&&`, `||`, or `/` operators must be parenthesized:
  693. ```just
  694. arch := "wasm"
  695. test triple=(arch + "-unknown-unknown") input=(arch / "input.dat"):
  696. ./test {{triple}}
  697. ```
  698. The last parameter of a recipe may be variadic, indicated with either a `+` or
  699. a `*` before the argument name:
  700. ```just
  701. backup +FILES:
  702. scp {{FILES}} me@server.com:
  703. ```
  704. Variadic parameters prefixed with `+` accept _one or more_ arguments and expand
  705. to a string containing those arguments separated by spaces:
  706. ```console
  707. $ just backup FAQ.md GRAMMAR.md
  708. scp FAQ.md GRAMMAR.md me@server.com:
  709. FAQ.md 100% 1831 1.8KB/s 00:00
  710. GRAMMAR.md 100% 1666 1.6KB/s 00:00
  711. ```
  712. Variadic parameters prefixed with `*` accept _zero or more_ arguments and
  713. expand to a string containing those arguments separated by spaces, or an empty
  714. string if no arguments are present:
  715. ```just
  716. commit MESSAGE *FLAGS:
  717. git commit {{FLAGS}} -m "{{MESSAGE}}"
  718. ```
  719. Variadic parameters can be assigned default values. These are overridden by
  720. arguments passed on the command line:
  721. ```just
  722. test +FLAGS='-q':
  723. cargo test {{FLAGS}}
  724. ```
  725. The number of arguments a variadic parameter accepts may be limited with the
  726. `[arg(ARG, min=MIN)]` and `[arg(ARG, max=MAX)]` attributes<sup>1.56.0</sup>,
  727. which require lists to be enabled:
  728. ```just
  729. set unstable
  730. set lists
  731. [arg('FILES', min='2', max='4')]
  732. backup +FILES:
  733. scp {{FILES}} me@server.com:
  734. ```
  735. `min` and `max` also apply to default values.
  736. `{{…}}` substitutions may need to be quoted if they contain spaces. For
  737. example, if you have the following recipe:
  738. ```just
  739. search QUERY:
  740. lynx https://www.google.com/?q={{QUERY}}
  741. ```
  742. And you type:
  743. ```console
  744. $ just search "cat toupee"
  745. ```
  746. `just` will run the command `lynx https://www.google.com/?q=cat toupee`, which
  747. will get parsed by `sh` as `lynx`, `https://www.google.com/?q=cat`, and
  748. `toupee`, and not the intended `lynx` and `https://www.google.com/?q=cat toupee`.
  749. You can fix this by adding quotes:
  750. ```just
  751. search QUERY:
  752. lynx 'https://www.google.com/?q={{QUERY}}'
  753. ```
  754. Parameters prefixed with a `$` will be exported as environment variables:
  755. ```just
  756. foo $bar:
  757. echo $bar
  758. ```
  759. Parameters may be constrained to match regular expression patterns using the
  760. `[arg("name", pattern=PATTERN)]` attribute<sup>1.45.0</sup>:
  761. ```just
  762. [arg('n', pattern='\d+')]
  763. double n:
  764. echo $(({{n}} * 2))
  765. ```
  766. The value of `pattern` may be a const expression<sup>1.55.0</sup>.
  767. A leading `^` and trailing `$` are added to the pattern, so it must match the
  768. entire argument value.
  769. You may constrain the pattern to a number of alternatives using the `|`
  770. operator:
  771. ```just
  772. [arg('flag', pattern='--help|--version')]
  773. info flag:
  774. just {{flag}}
  775. ```
  776. Regular expressions are provided by the
  777. [Rust `regex` crate](https://docs.rs/regex/latest/regex/). See the
  778. [syntax documentation](https://docs.rs/regex/latest/regex/#syntax) for usage
  779. examples.
  780. Usage information for a recipe may be printed with the `--usage`
  781. subcommand<sup>1.46.0</sup>:
  782. ```console
  783. $ just --usage foo
  784. Usage: just foo [OPTIONS] bar
  785. Arguments:
  786. bar
  787. ```
  788. Help strings may be added to arguments using the `[arg(ARG, help=HELP)]` attribute:
  789. ```just
  790. [arg("bar", help="hello")]
  791. foo bar:
  792. ```
  793. The value `help` may be a const expression<sup>1.55.0</sup>.
  794. ```console
  795. $ just --usage foo
  796. Usage: just foo bar
  797. Arguments:
  798. bar hello
  799. ```
  800. #### Recipe Flags and Options
  801. Recipe parameters are positional by default.
  802. In this `justfile`:
  803. ```just
  804. @foo bar:
  805. echo bar={{bar}}
  806. ```
  807. The parameter `bar` is positional:
  808. ```console
  809. $ just foo hello
  810. bar=hello
  811. ```
  812. The `[arg(ARG, long=OPTION)]`<sup>1.46.0</sup> attribute can be used to make a
  813. parameter a long option.
  814. In this `justfile`:
  815. ```just
  816. [arg("bar", long="bar")]
  817. foo bar:
  818. ```
  819. The parameter `bar` is given with the `--bar` option:
  820. ```console
  821. $ just foo --bar hello
  822. bar=hello
  823. ```
  824. Options may also be passed with `--name=value` syntax:
  825. ```console
  826. $ just foo --bar=hello
  827. bar=hello
  828. ```
  829. The value of `long` may be omitted, in which case the option defaults to the
  830. name of the parameter. With the following justfile, `bar` may be passed with
  831. `--bar`:
  832. ```just
  833. [arg("bar", long)]
  834. foo bar:
  835. ```
  836. The `[arg(ARG, short=OPTION)]`<sup>1.46.0</sup> attribute can be used to make a
  837. parameter a short option.
  838. In this `justfile`:
  839. ```just
  840. [arg("bar", short="b")]
  841. foo bar:
  842. ```
  843. The parameter `bar` is given with the `-b` option:
  844. ```console
  845. $ just foo -b hello
  846. bar=hello
  847. ```
  848. The value of `short` may be omitted, in which case the option defaults to the
  849. first character of the name of the parameter. With the following justfile,
  850. `bar` may be passed with `-b`:
  851. ```just
  852. [arg("bar", short)]
  853. foo bar:
  854. ```
  855. If a parameter has both a long and short option, it may be passed using either.
  856. Multiple short options may be combined<sup>1.55.0</sup>, for example `-abc` is
  857. equivalent to `-a -b -c`. A short option which takes a value may appear last,
  858. for example `-abcd VALUE`.
  859. Variadic `*` and `+` parameters may be options, in which case the option is
  860. repeatable, with each occurrence contributing one value:
  861. ```just
  862. [arg('file', long)]
  863. backup +file:
  864. scp {{file}} me@server.com:
  865. ```
  866. ```console
  867. $ just backup --file FAQ.md --file GRAMMAR.md
  868. scp FAQ.md GRAMMAR.md me@server.com:
  869. ```
  870. As with positional variadic parameters, `+` options must be passed at least
  871. once, whereas `*` options may be omitted.
  872. The `[arg(ARG, value=VALUE, …)]`<sup>1.46.0</sup> attribute can be used with
  873. `long` or `short` to make a parameter a flag which does not take a value.
  874. `VALUE` may be an expression<sup>1.54.0</sup>.
  875. In this `justfile`:
  876. ```just
  877. [arg("bar", long="bar", value="hello")]
  878. foo bar:
  879. ```
  880. The parameter `bar` is given with the `--bar` option, but does not take a
  881. value, and instead takes the value given in the `[arg]` attribute:
  882. ```console
  883. $ just foo --bar
  884. bar=hello
  885. ```
  886. This is useful for unconditionally requiring a flag like `--force` on dangerous
  887. commands.
  888. A flag is optional if its parameter has a default:
  889. ```just
  890. [arg("bar", long="bar", value="hello")]
  891. foo bar="goodbye":
  892. ```
  893. Causing it to receive the default when not passed in the invocation:
  894. ```console
  895. $ just foo
  896. bar=goodbye
  897. ```
  898. If `--help` or `-h` is passed to a recipe that does not define that option, the
  899. recipe's help string is printed and execution stops<sup>master</sup>.
  900. ### Avoiding Argument Splitting
  901. Given this `justfile`:
  902. ```just
  903. foo argument:
  904. touch {{argument}}
  905. ```
  906. The following command will create two files, `some` and `argument.txt`:
  907. ```console
  908. $ just foo "some argument.txt"
  909. ```
  910. The user's shell will parse `"some argument.txt"` as a single argument, but
  911. when `just` replaces `touch {{argument}}` with `touch some argument.txt`, the
  912. quotes are not preserved, and `touch` will receive two arguments.
  913. There are a few ways to avoid this: quoting, positional arguments, and exported
  914. arguments.
  915. #### Quoting
  916. Quotes can be added around the `{{argument}}` interpolation:
  917. ```just
  918. foo argument:
  919. touch '{{argument}}'
  920. ```
  921. This preserves `just`'s ability to catch variable name typos before running,
  922. for example if you were to write `{{argument}}`, but will not do what you want
  923. if the value of `argument` contains single quotes.
  924. #### Positional Arguments
  925. The `positional-arguments` setting causes all arguments to be passed as
  926. positional arguments, allowing them to be accessed with `$1`, `$2`, …, and
  927. `$@`, which can then be double-quoted to avoid further splitting by the shell:
  928. ```just
  929. set positional-arguments
  930. foo argument:
  931. touch "$1"
  932. ```
  933. This defeats `just`'s ability to catch typos, for example if you type `$2`
  934. instead of `$1`, but works for all possible values of `argument`, including
  935. those with double quotes.
  936. #### Exported Arguments
  937. All arguments are exported when the `export` setting is set:
  938. ```just
  939. set export
  940. foo argument:
  941. touch "$argument"
  942. ```
  943. Or individual arguments may be exported by prefixing them with `$`:
  944. ```just
  945. foo $argument:
  946. touch "$argument"
  947. ```
  948. This defeats `just`'s ability to catch typos, for example if you type
  949. `$argument`, but works for all possible values of `argument`, including those
  950. with double quotes.
  951. ### Positional Arguments
  952. If `positional-arguments` is `true`, recipe arguments will be passed as
  953. positional arguments to commands. For shell recipes, argument `$0` will be the
  954. name of the recipe.
  955. For example, running this recipe:
  956. ```just
  957. set positional-arguments
  958. @foo bar:
  959. echo $0
  960. echo $1
  961. ```
  962. Will produce the following output:
  963. ```console
  964. $ just foo hello
  965. foo
  966. hello
  967. ```
  968. When using an `sh`-compatible shell, such as `bash` or `zsh`, `$@` expands to
  969. the positional arguments given to the recipe, starting from one. When used
  970. within double quotes as `"$@"`, arguments including whitespace will be passed
  971. on as if they were double-quoted. That is, `"$@"` is equivalent to `"$1" "$2"`…
  972. When there are no positional parameters, `"$@"` and `$@` expand to nothing
  973. (i.e., they are removed).
  974. This example recipe will print arguments one by one on separate lines:
  975. ```just
  976. set positional-arguments
  977. @test *args='':
  978. bash -c 'while (( "$#" )); do echo - $1; shift; done' -- "$@"
  979. ```
  980. Running it with _two_ arguments:
  981. ```console
  982. $ just test foo "bar baz"
  983. - foo
  984. - bar baz
  985. ```
  986. Positional arguments may also be turned on a per-recipe basis with the
  987. `[positional-arguments]` attribute<sup>1.29.0</sup>:
  988. ```just
  989. [positional-arguments]
  990. @foo bar:
  991. echo $0
  992. echo $1
  993. ```
  994. Note that PowerShell does not handle positional arguments in the same way as
  995. other shells, so turning on positional arguments will likely break recipes that
  996. use PowerShell.
  997. If using PowerShell 7.4 or better, the `-CommandWithArgs` flag will make
  998. positional arguments work as expected:
  999. ```just
  1000. set shell := ['pwsh.exe', '-CommandWithArgs']
  1001. set positional-arguments
  1002. print-args a b c:
  1003. Write-Output @($args[1..($args.Count - 1)])
  1004. ```
  1005. ### Dependencies
  1006. Dependencies run before recipes that depend on them:
  1007. ```just
  1008. a: b
  1009. @echo A
  1010. b:
  1011. @echo B
  1012. ```
  1013. ```
  1014. $ just a
  1015. B
  1016. A
  1017. ```
  1018. In a given invocation of `just`, a recipe with the same arguments will only run
  1019. once, regardless of how many times it appears in the command-line invocation,
  1020. or how many times it appears as a dependency:
  1021. ```just
  1022. a:
  1023. @echo A
  1024. b: a
  1025. @echo B
  1026. c: a
  1027. @echo C
  1028. ```
  1029. ```
  1030. $ just a a a a a
  1031. A
  1032. $ just b c
  1033. A
  1034. B
  1035. C
  1036. ```
  1037. Multiple recipes may depend on a recipe that performs some kind of setup, and
  1038. when those recipes run, that setup will only be performed once:
  1039. ```just
  1040. build:
  1041. cc main.c
  1042. test-foo: build
  1043. ./a.out --test foo
  1044. test-bar: build
  1045. ./a.out --test bar
  1046. ```
  1047. ```
  1048. $ just test-foo test-bar
  1049. cc main.c
  1050. ./a.out --test foo
  1051. ./a.out --test bar
  1052. ```
  1053. Recipes in a given run are only skipped when they receive the same arguments:
  1054. ```just
  1055. build:
  1056. cc main.c
  1057. test TEST: build
  1058. ./a.out --test {{TEST}}
  1059. ```
  1060. ```
  1061. $ just test foo test bar
  1062. cc main.c
  1063. ./a.out --test foo
  1064. ./a.out --test bar
  1065. ```
  1066. #### Running Recipes at the End of a Recipe
  1067. Normal dependencies of a recipe always run before a recipe starts. That is to
  1068. say, the dependee always runs before the depender. These dependencies are
  1069. called "prior dependencies".
  1070. A recipe can also have subsequent dependencies, which run immediately after the
  1071. recipe and are introduced with an `&&`:
  1072. ```just
  1073. a:
  1074. echo 'A!'
  1075. b: a && c d
  1076. echo 'B!'
  1077. c:
  1078. echo 'C!'
  1079. d:
  1080. echo 'D!'
  1081. ```
  1082. …running _b_ prints:
  1083. ```console
  1084. $ just b
  1085. echo 'A!'
  1086. A!
  1087. echo 'B!'
  1088. B!
  1089. echo 'C!'
  1090. C!
  1091. echo 'D!'
  1092. D!
  1093. ```
  1094. #### Running Recipes in the Middle of a Recipe
  1095. `just` doesn't support running recipes in the middle of another recipe, but you
  1096. can call `just` recursively in the middle of a recipe. Given the following
  1097. `justfile`:
  1098. ```just
  1099. a:
  1100. echo 'A!'
  1101. b: a
  1102. echo 'B start!'
  1103. just c
  1104. echo 'B end!'
  1105. c:
  1106. echo 'C!'
  1107. ```
  1108. …running _b_ prints:
  1109. ```console
  1110. $ just b
  1111. echo 'A!'
  1112. A!
  1113. echo 'B start!'
  1114. B start!
  1115. echo 'C!'
  1116. C!
  1117. echo 'B end!'
  1118. B end!
  1119. ```
  1120. This has limitations, since recipe `c` is run with an entirely new invocation
  1121. of `just`: Assignments will be recalculated, dependencies might run twice, and
  1122. command line arguments will not be propagated to the child `just` process.
  1123. ### Parallelism
  1124. Dependencies may be run in parallel with the `[parallel]` attribute.
  1125. In this `justfile`, `foo`, `bar`, and `baz` will execute in parallel when
  1126. `main` is run:
  1127. ```just
  1128. [parallel]
  1129. main: foo bar baz
  1130. foo:
  1131. sleep 1
  1132. bar:
  1133. sleep 1
  1134. baz:
  1135. sleep 1
  1136. ```
  1137. The number of simultaneously running recipes may be limited with the `--jobs`
  1138. option<sup>1.56.0</sup>. The `num_jobs()` function returns the number of jobs,
  1139. falling back to the empty list if `--jobs` was not passed.
  1140. GNU `parallel` may be used to run recipe lines concurrently:
  1141. ```just
  1142. parallel:
  1143. #!/usr/bin/env -S parallel --shebang --ungroup --jobs {{ num_cpus() }}
  1144. echo task 1 start; sleep 3; echo task 1 done
  1145. echo task 2 start; sleep 3; echo task 2 done
  1146. echo task 3 start; sleep 3; echo task 3 done
  1147. echo task 4 start; sleep 3; echo task 4 done
  1148. ```
  1149. ### Documentation Comments
  1150. Comments immediately preceding a recipe will appear in `just --list`:
  1151. ```just
  1152. # build stuff
  1153. build:
  1154. ./bin/build
  1155. # test stuff
  1156. test:
  1157. ./bin/test
  1158. ```
  1159. ```console
  1160. $ just --list
  1161. Available recipes:
  1162. build # build stuff
  1163. test # test stuff
  1164. ```
  1165. The `[doc]` attribute can be used to set or suppress a recipe's doc comment:
  1166. ```just
  1167. # This comment won't appear
  1168. [doc('Build stuff')]
  1169. build:
  1170. ./bin/build
  1171. # This one won't either
  1172. [doc]
  1173. test:
  1174. ./bin/test
  1175. ```
  1176. ```console
  1177. $ just --list
  1178. Available recipes:
  1179. build # Build stuff
  1180. test
  1181. ```
  1182. The value of `[doc]` may be a const expression<sup>1.56.0</sup>.
  1183. ### Groups
  1184. Recipes and modules may be annotated with one or more group names:
  1185. ```just
  1186. [group('lint')]
  1187. js-lint:
  1188. echo 'Running JS linter…'
  1189. [group('rust recipes')]
  1190. [group('lint')]
  1191. rust-lint:
  1192. echo 'Running Rust linter…'
  1193. [group('lint')]
  1194. cpp-lint:
  1195. echo 'Running C++ linter…'
  1196. # not in any group
  1197. email-everyone:
  1198. echo 'Sending mass email…'
  1199. ```
  1200. Recipes are listed by group:
  1201. ```
  1202. $ just --list
  1203. Available recipes:
  1204. email-everyone # not in any group
  1205. [lint]
  1206. cpp-lint
  1207. js-lint
  1208. rust-lint
  1209. [rust recipes]
  1210. rust-lint
  1211. ```
  1212. `just --list --unsorted` prints recipes in their justfile order within each group:
  1213. ```
  1214. $ just --list --unsorted
  1215. Available recipes:
  1216. (no group)
  1217. email-everyone # not in any group
  1218. [lint]
  1219. js-lint
  1220. rust-lint
  1221. cpp-lint
  1222. [rust recipes]
  1223. rust-lint
  1224. ```
  1225. Groups can be listed with `--groups`:
  1226. ```
  1227. $ just --groups
  1228. Recipe groups:
  1229. lint
  1230. rust recipes
  1231. ```
  1232. Use `just --groups --unsorted` to print groups in their justfile order.
  1233. ### Aliases
  1234. Aliases allow recipes to be invoked on the command line with alternative names:
  1235. ```just
  1236. alias b := build
  1237. build:
  1238. echo 'Building!'
  1239. ```
  1240. ```console
  1241. $ just b
  1242. echo 'Building!'
  1243. Building!
  1244. ```
  1245. The target of an alias may be a recipe in a submodule:
  1246. ```justfile
  1247. mod foo
  1248. alias baz := foo::bar
  1249. ```
  1250. Or a module<sup>1.55.0</sup>:
  1251. ```justfile
  1252. mod frontend
  1253. alias f := frontend
  1254. ```
  1255. ```console
  1256. $ just f build
  1257. ```
  1258. ### Private Recipes
  1259. Recipes and aliases whose name starts with a `_` are omitted from `just --list`:
  1260. ```just
  1261. test: _test-helper
  1262. ./bin/test
  1263. _test-helper:
  1264. ./bin/super-secret-test-helper-stuff
  1265. ```
  1266. ```console
  1267. $ just --list
  1268. Available recipes:
  1269. test
  1270. ```
  1271. And from `just --summary`:
  1272. ```console
  1273. $ just --summary
  1274. test
  1275. ```
  1276. The `[private]` attribute<sup>1.10.0</sup> may also be used to hide recipes or
  1277. aliases without needing to change the name:
  1278. ```just
  1279. [private]
  1280. foo:
  1281. [private]
  1282. alias b := bar
  1283. bar:
  1284. ```
  1285. ```console
  1286. $ just --list
  1287. Available recipes:
  1288. bar
  1289. ```
  1290. This is useful for helper recipes which are only meant to be used as
  1291. dependencies of other recipes.
  1292. ### Enabling and Disabling Items
  1293. The `[android]`, `[dragonfly]`, `[freebsd]`, `[linux]`, `[macos]`, `[netbsd]`,
  1294. `[openbsd]`, `[unix]`, and `[windows]` attributes are conditional attributes.
  1295. By default, items are always enabled. An item with one or more conditional
  1296. attributes will only be enabled when one or more of those conditional
  1297. attributes is active.
  1298. The conditional attributes originally applied only to recipes, but may now be
  1299. applied to all top-level items<sup>1.56.0</sup>.
  1300. This can be used to write `justfile`s that behave differently depending on
  1301. which operating system they run on. The `run` recipe in this `justfile` will
  1302. compile and run `main.c`, using a different C compiler and using the correct
  1303. output binary name for that compiler depending on the operating system:
  1304. ```just
  1305. [unix]
  1306. run:
  1307. cc main.c
  1308. ./a.out
  1309. [windows]
  1310. run:
  1311. cl main.c
  1312. main.exe
  1313. ```
  1314. Similarly, a setting can be made conditional on the current operating system:
  1315. ```just
  1316. [unix]
  1317. set shell := ['sh', '-cu']
  1318. [windows]
  1319. set shell := ['cmd', '/c']
  1320. ```
  1321. ### Allow Duplicate Recipes
  1322. If `allow-duplicate-recipes` is set to `true`, defining multiple recipes with
  1323. the same name is not an error and the last definition is used. Defaults to
  1324. `false`.
  1325. ```just
  1326. set allow-duplicate-recipes
  1327. @foo:
  1328. echo foo
  1329. @foo:
  1330. echo bar
  1331. ```
  1332. ```console
  1333. $ just foo
  1334. bar
  1335. ```
  1336. Expressions
  1337. -----------
  1338. ### Variables and Assignments
  1339. Module-level variables may be created by assigning them a value with `:=`:
  1340. ```just
  1341. foo := "hello"
  1342. bar := "world"
  1343. baz:
  1344. echo {{ foo + " " + bar }}
  1345. ```
  1346. All variables in a module may be printed:
  1347. ```console
  1348. $ just --evaluate
  1349. bar := "world"
  1350. foo := "hello"
  1351. ```
  1352. Or the value of a single variable:
  1353. ```console
  1354. $ just --evaluate foo
  1355. hello
  1356. ```
  1357. All variables in a submodule or a single variable in a submodule may be printed
  1358. with a path to the submodule or variable<sup>1.49.0</sup>:
  1359. ```console
  1360. $ just --evaluate bob::bar
  1361. x := "world"
  1362. y := "hello"
  1363. $ just --evaluate bob::bar::y
  1364. hello
  1365. ```
  1366. The format of exported variables may be controlled with
  1367. `--evaluate-format`<sup>1.49.0</sup>:
  1368. ```console
  1369. $ just --evaluate --evaluate-format shell
  1370. bar="world"
  1371. foo="hello"
  1372. ```
  1373. The default format is `--evaluate-format just`:
  1374. ```console
  1375. $ just --evaluate --evaluate-format just
  1376. bar := "world"
  1377. foo := "hello"
  1378. ```
  1379. ### Allow Duplicate Variables
  1380. If `allow-duplicate-variables` is set to `true`, defining multiple variables
  1381. with the same name is not an error and the last definition is used. Defaults to
  1382. `false`.
  1383. ```just
  1384. set allow-duplicate-variables
  1385. a := "foo"
  1386. a := "bar"
  1387. @foo:
  1388. echo {{a}}
  1389. ```
  1390. ```console
  1391. $ just foo
  1392. bar
  1393. ```
  1394. ### Lazy
  1395. The `lazy` setting<sup>1.47.0</sup> causes the evaluator to skip evaluating
  1396. unused variables. This can be beneficial when a `justfile` contains variables
  1397. that are expensive to evaluate but only sometimes used.
  1398. In the following `justfile`, `token` will be skipped when only invoking `bar`:
  1399. ```just
  1400. set lazy
  1401. token := `expensive-script-to-get-credentials`
  1402. foo:
  1403. curl -H "Authorization: Bearer {{ token }}" https://example.com/foo
  1404. bar:
  1405. cargo test
  1406. ```
  1407. Because `just` cannot determine when exported variables are used, assignments
  1408. with `export` and assignments in a module with `set export` will always be
  1409. evaluated.
  1410. Assignments with the `eager`<sup>1.47.1</sup> keyword are always evaluated.
  1411. In the following `justfile`, `setup` is evaluated regardless of whether it is
  1412. used:
  1413. ```just
  1414. set lazy
  1415. eager setup := `echo 'setup: yes' > config.yaml`
  1416. test:
  1417. cargo test
  1418. ```
  1419. ### Expressions and Substitutions
  1420. Various operators and function calls are supported in expressions, which may be
  1421. used in assignments, default recipe arguments, and inside recipe body `{{…}}`
  1422. substitutions.
  1423. ```just
  1424. tmpdir := `mktemp -d`
  1425. version := "0.2.7"
  1426. tardir := tmpdir / "awesomesauce-" + version
  1427. tarball := tardir + ".tar.gz"
  1428. config := quote(config_dir() / ".project-config")
  1429. publish:
  1430. rm -f {{tarball}}
  1431. mkdir {{tardir}}
  1432. cp README.md *.c {{ config }} {{tardir}}
  1433. tar zcvf {{tarball}} {{tardir}}
  1434. scp {{tarball}} me@server.com:release/
  1435. rm -rf {{tarball}} {{tardir}}
  1436. ```
  1437. #### Concatenation
  1438. The `+` operator returns the left-hand argument concatenated with the
  1439. right-hand argument:
  1440. ```just
  1441. foobar := 'foo' + 'bar'
  1442. ```
  1443. #### Logical Operators
  1444. The logical operators `&&` and `||` can be used to coalesce
  1445. values<sup>1.37.0</sup>, similar to Python's `and` and `or`. The only false
  1446. value is the empty list `[]`; every other value, including the empty string
  1447. `''`, is true.
  1448. These operators require `set lists`<sup>1.53.0</sup>, which is currently
  1449. unstable.
  1450. The `&&` operator returns the empty list if the left-hand argument is false,
  1451. otherwise it returns the right-hand argument:
  1452. ```justfile
  1453. foo := [] && 'goodbye' # []
  1454. bar := 'hello' && 'goodbye' # 'goodbye'
  1455. ```
  1456. The `||` operator returns the left-hand argument if it is true, otherwise it
  1457. returns the right-hand argument:
  1458. ```justfile
  1459. foo := [] || 'goodbye' # 'goodbye'
  1460. bar := 'hello' || 'goodbye' # 'hello'
  1461. ```
  1462. #### Joining Paths
  1463. The `/` operator can be used to join two strings with a slash:
  1464. ```just
  1465. foo := "a" / "b"
  1466. ```
  1467. ```
  1468. $ just --evaluate foo
  1469. a/b
  1470. ```
  1471. Note that a `/` is added even if one is already present:
  1472. ```just
  1473. foo := "a/"
  1474. bar := foo / "b"
  1475. ```
  1476. ```
  1477. $ just --evaluate bar
  1478. a//b
  1479. ```
  1480. Absolute paths can also be constructed<sup>1.5.0</sup>:
  1481. ```just
  1482. foo := / "b"
  1483. ```
  1484. ```
  1485. $ just --evaluate foo
  1486. /b
  1487. ```
  1488. The `/` operator uses the `/` character, even on Windows. Thus, using the `/`
  1489. operator should be avoided with paths that use universal naming convention
  1490. (UNC), i.e., those that start with `\\`, since forward slashes are not
  1491. supported with UNC paths.
  1492. #### Escaping `{{`
  1493. To write a recipe containing `{{`, use `{{{{`:
  1494. ```just
  1495. braces:
  1496. echo 'I {{{{LOVE}} curly braces!'
  1497. ```
  1498. (An unmatched `}}` is ignored, so it doesn't need to be escaped.)
  1499. Another option is to put all the text you'd like to escape inside of an
  1500. interpolation:

Lines 2,001–6,061 are not shown. The link to the file on GitHub has every line.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.