From 8c0bb3dde7e9e27711ab0435b9bfdc60de6dc249 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Mon, 13 Jun 2022 18:28:22 -0700 Subject: [PATCH] Add notes about environment variables to readme (#1229) --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f752ce..9ff4b2d 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ This readme is also available as a [book](https://just.systems/man/en/); -(中文文档在 [这里](README.中文.md), 快看过来!) +(中文文档在 [这里](https://github.com/casey/just/blob/master/README.中文.md), 快看过来!) Commands, called recipes, are stored in a file called `justfile` with syntax inspired by `make`: @@ -1594,6 +1594,22 @@ foo: echo $x ``` +### Sharing Environment Variables Between Recipes + +Each line of each recipe is executed by a fresh shell, so it is not possible to share environment variables between recipes. + +#### Using Python Virtual Environments + +Some tools, like [Python's venv](https://docs.python.org/3/library/venv.html), require loading environment variables in order to work, making them challenging to use with `just`. As a workaround, you can execute the virtual environment binaries directly: + +```make +venv: + [ -d foo ] || python3 -m venv foo + +run: venv + ./foo/bin/python3 main.py +``` + ### Changing the Working Directory in a Recipe Each recipe line is executed by a new shell, so if you change the working directory on one line, it won't have an effect on later lines: