Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add information about venv and environment variables to readme #1229

Merged
merged 2 commits into from
Jun 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:

Expand Down Expand Up @@ -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:
Expand Down