Open nikitajz opened 7 months ago
Seems loosely related https://github.com/pypa/hatch/issues/1097 and https://github.com/pypa/hatch/issues/1126
+1 to this - it tripped me up because the docs say “dependencies are automatically synced” each time the environment is used, but it didn’t occur to me that this would mean only package dependencies and not python version.
Issue
When
tool.hatch.envs.default.python
is specified after the first run (was not before) or amended, hatch keeps using the old version of python. In order to actually apply the change, the old environment should be deleted. It might not be interpreted as a bug per ce, but it's not what is expected intuitively.How to reproduce
Stage 1: No python version is specified under
tool.hatch.*
pyproject.toml:
Run:
hatch run pytest
Hatch installs the latest available python version, for example, python=3.12Stage 2: Specify python version explicitly
pyproject.toml:
Run:
hatch run test
Expected: Hatch rebuild environment usingpython=3.9
Actual: Hatch keeps usingpython=3.12
To use
python=3.9
you have to remove existing env manually, for example,hatch env prune