hatch build fails with default env matrix
Hey,
First of all, thanks for this great tool. I'm not sure if this is a wrong usage or just an issue with hatch, but the following configuration fails:
[tool.hatch.envs.default]
dependencies = [
"pytest",
]
[tool.hatch.envs.default.scripts]
# some commands
[[tool.hatch.envs.default.matrix]]
sqlalchemy = ["1.4", "2.0"]
Then running hatch build fails with the following error:
Unknown environment: default
But if you change the environment name from default to something else, it works fine:
[tool.hatch.envs.test]
dependencies = [
"pytest",
]
[tool.hatch.envs.test.scripts]
# some commands
[[tool.hatch.envs.test.matrix]]
sqlalchemy = ["1.4", "2.0"]
Apparently it has something to do with the default environment and adding matrix option to it.
I had the same problem.
Thanks I will fix this
I'm facing the same issue when trying to build for several mypyc targets.
I work around it by adding this to the toml:
[tool.hatch.envs.test]
dependencies = [
"pytest",
"pytest-cov",
"build"
]
[tool.hatch.envs.default.scripts]
version = "python --version"
cov = "pytest --cov-report=term --cov-config=pyproject.toml"
no-cov = "cov --no-cov {args}"
build = "python -m build"
[[tool.hatch.envs.test.matrix]]
python = [ "38", "39", "310", "311"]
and then building with:
hatch run test:build
Rather silly to add build as a dependency and then use a matrix from another environment (Though I'm sure you could also use matrix + default) but as a workaround this is fine.
The problem seems to be linked to use of the environment matrix in the pyproject.toml. Without using it, the command "hatch env show" prints the default environment as a standalone environment .
If you use "hatch build" without the environment matrix it will work.
I tried to use the following command based on the last comment but i got a "Permission denied" error on use.
hatch run default:build