@@ -191,6 +191,43 @@ location can be changed via the ``TOX_CONFIG_FILE`` environment variable.
191191 # Force editable install for a specific environment
192192 tox run -e 3.13 -x " testenv:3.13.package=editable"
193193
194+ .. _howto_out_of_tree_envs :
195+
196+ ********************************************
197+ Keep environments outside the project tree
198+ ********************************************
199+
200+ By default tox creates its environments in a ``.tox `` directory next to the configuration file. To keep them out of the
201+ project tree, point :ref: `work_dir ` at a location built from the ``{home} `` and ``{tox_root_name} `` substitutions:
202+
203+ .. tab :: TOML
204+
205+ .. code-block :: toml
206+
207+ work_dir = "{home}/.local/state/tox/{tox_root_name}"
208+
209+ .. tab :: INI (deprecated)
210+
211+ .. code-block :: ini
212+
213+ [tox]
214+ work_dir = {home}/.local/state/tox/{tox_root_name}
215+
216+ With this configuration a project checked out at ``~/src/magic `` keeps its environments in ``~/.local/state/tox/magic ``.
217+ Verify the resolved location with:
218+
219+ .. code-block :: bash
220+
221+ $ tox config --core -k work_dir
222+ [tox]
223+ work_dir = /home/user/.local/state/tox/magic
224+
225+ Substitutions resolve in the project configuration file only: the ``--workdir `` CLI flag and the user-level
226+ configuration file take literal paths, so this setting belongs in ``tox.toml ``. Since ``{tox_root_name} `` is the name of
227+ the project directory, two projects checked out under the same directory name share a work directory; give one of them
228+ an explicit path if that happens. See :ref: `work-dir-placement ` for the trade-offs of moving environments out of the
229+ tree.
230+
194231**********************************
195232 Use labels to group environments
196233**********************************
0 commit comments