-
-
Notifications
You must be signed in to change notification settings - Fork 348
Description
Problem
Sometimes it happens that hatch env create ... or hatch test or hatch run ... encounter an error while creating (or more rarely when synchronizing) the environment, because of something like a dependency resolution or build error, {pre,post}-install-commands failing, and so on.
If I don’t immediately resolve the issue, that causes a broken environment to remain, with nothing or only a few packages installed into it.
Subsequent commands will try to interact with that environment and fail in unexpected ways or generate results that don’t reflect what would happen had the environment creation fully succeeded.
Proposed solution
I was thinking of two solutions:
- Hatch should delete environments if they can’t be fully created or synchronized without error, or
- Hatch should mark them in a way that subsequent commands trying to use it try to re-create them or just error with a message that mentions the user could try
hatch env remove <env-name>
The second solution doesn’t interact with other tools trying to use the environment (like language servers), but it has the advantage of users being able to inspect the broken environment, in case their content is related to the error. So I think the best solution would be a modified 1.:
- Environment-syncing commands should delete environments when their setup causes an error, unless
--keep-env(or so) is specified, which allows users to opt into keeping broken envs around for debugging purposes.