just: Choose the Shell with set shell
set shell tells just which interpreter and flags to use when running recipe lines.
just defaults to sh -cu, which lacks bash features like pipefail and arrays. set shell switches recipes to bash (or PowerShell on Windows) consistently.
What it does
set shell := ["program", "arg", ...] overrides the interpreter just uses for every non-shebang recipe line. A common value is ["bash", "-uc"]. set windows-shell sets a separate shell for Windows runners. This is global to the justfile, so all recipes share the same shell semantics.
Common usage
# justfile
set shell := ["bash", "-uc"]
set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
pipeline:
set -o pipefail
curl -sf https://example.com | grep -q ok
# bash arrays now work because the shell is bash
matrix:
arr=(a b c); echo "${arr[1]}"Syntax
| Setting | What it does |
|---|---|
| set shell := ["bash", "-uc"] | Run recipe lines with bash and the -u, -c flags |
| set shell := ["sh", "-eu"] | Default-style POSIX shell with strict flags |
| set windows-shell := [...] | Separate shell used on Windows runners |
| (default) | just uses sh -cu when no shell is set |
| #!/usr/bin/env bash | Per-recipe alternative for one-off scripts |
In CI
If recipes use pipefail, [[ ]], or arrays, set shell := ["bash", "-uc"] so they behave the same on every runner instead of relying on whatever /bin/sh links to. On cross-platform matrices, pair it with set windows-shell so Windows jobs do not try to run sh syntax.
Common errors in CI
"syntax error: unexpected" on a pipeline or array usually means recipes ran under dash-linked /bin/sh; add set shell := ["bash", "-uc"]. "error: Recipe X could not be run because just could not find the shell: No such file or directory" means the named shell is not installed. On Alpine, bash is absent by default, so set shell to sh or install bash first.