HATCH-ENV-RUN(1)

πŸ“¦
version 1.16.4 Β· 2 versions
, in epel 10, fedora 43, fedora 44

πŸ‘‘ hatch env run β€” the vibe

okay bestie, so this is hatch-env-run(1), a User Commands manual page, and it's literally the glow-up your project environments have been waiting for. it's giving "run my commands, but make it inside the right environment." πŸ’…


✨ NAME ✨

hatch env run β€” run commands within project environments 🫢


🌸 SYNOPSIS 🌸

hatch env run [OPTIONS] ARGS...

that's it. that's the whole entrance. ARGS... is your moment, bestie. πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

so here's the tea: the -e / --env option overrides the equivalent root option and the HATCH_ENV environment variable. no cap. it just wins. periodt.

and then the -i / --include and -x / --exclude options? they let you include or exclude certain variables, optionally followed by specific comma-separated values, and β€” this is the iconic part β€” they may be selected multiple times. yes you can stack them. yes it's a serve. πŸŽ€


🌈 OPTIONS 🌈

  • -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 🧚
  • --force-continue β€” run every command and if there were any errors exit with the first code πŸ’€ (yes, every command. it does not stop. it does not chill.)
  • --ignore-compat β€” ignore incompatibility when selecting specific environments πŸ”₯
  • -h, --help β€” show a help message and exit 🌸

πŸ¦‹ NOTES πŸ¦‹

lowkey the most important lore on this whole page, so pay attention:

the inclusion option is treated as an intersection while the exclusion option is treated as a union.

translating that for the group chat: an environment must match all of the included variables to be selected, while matching any of the excluded variables will prevent selection. highkey simple once you say it like that. πŸ’œ


πŸ“ EXAMPLES πŸ“

say your config looks like this:

[[tool.hatch.envs.test.matrix]]
   python = ["3.9", "3.10"]
   version = ["42", "3.14", "9000"]

then running:

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

would execute pytest in the environments test.py3.10-42 and test.py3.10-3.14. πŸ”₯

and note β€” and this is the cute little detail β€” py may be used as an alias for python. iykyk. ⭐


πŸŽ€ SEE ALSO πŸŽ€


and that's the whole page bestie, ily, go run some commands in the correct environment πŸ’–βœ¨

this little masterpiece is brought to you by the HATCH-ENV-RUN(1) era, dated August 2024 β€” the source/version of the whole thing. mwah. πŸ’‹πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from