hatch-env-run - Man Page

hatch env run – Run commands within project environments


hatch env run [Options] [ARGS]...


The -e /--env option overrides the equivalent root option and the HATCH_ENV environment variable.

If environments provide matrices, then you may use the -i / --include and -x / --exclude options to select or exclude certain variables, optionally followed by specific comma-separated values.


-e,  --env TEXT

The environments to target

-i,  --include TEXT

The matrix variables to include

-x,  --exclude TEXT

The matrix variables to exclude

-f,  --filter TEXT

The JSON data used to select environments


Run every command and if there were any errors exit with the first code


Ignore incompatibility when selecting specific environments

-h,  --help

Show a help message and exit


For example, if you have the following configuration:

python = ["39", "310"]
version = ["42", "3.14", "9000"]
python = ["39", "310"]
version = ["42", "3.14", "9000"]

then running:

hatch env run -i py=310 -x -version=9000 test:pytest

would execute pytest in the environments test.py310-42 and test.py310-3.14. Note that py may be used as an alias for python.

See Also


hatch-env-create(1), hatch-env-find(1), hatch-env-prune(1), hatch-env-remove(1), hatch-env-show(1)

hatch-env(1), hatch(1)

Referenced By

hatch-env(1), hatch-env-create(1), hatch-env-find(1), hatch-env-prune(1), hatch-env-remove(1), hatch-env-show(1), hatch-run(1).

October 2022