hatch icon indicating copy to clipboard operation
hatch copied to clipboard

`hatch prune env` doesn't prune internal environments

Open warsaw opened this issue 1 month ago • 2 comments

One reason why this is a problem (I think) is that if say your hatch-static-analysis environment was set up to use a version of Python that's no longer on your system, you can end up with errors like this:

/Users/xxx/Library/Application
Support/hatch/env/.internal/hatch-static-analysis/projectjCyxL-Ja/hatch-static-analysis/bin/python3`
  Caused by: Broken symlink at `/Users/xxx/Library/Application
Support/hatch/env/.internal/hatch-static-analysis/project/jCyxL-Ja/hatch-static-analysis/bin/python3`, was the
underlying Python interpreter removed?

This happened to me now that Python 3.9 is EOL'd. The fix is to manually rm the internal hatch environment, but it would be better if hatch env prune did that for you, either automatically or with say a -i flag.

warsaw avatar Nov 28 '25 07:11 warsaw

This will be fixed in the next patch release. Do you think it's worth adding a flag like how the env show command doesn't consider internal environments by default?

ofek avatar Dec 01 '25 01:12 ofek

This will be fixed in the next patch release. Do you think it's worth adding a flag like how the env show command doesn't consider internal environments by default?

I think it makes sense for them to work the same way, so yes, adding a flag for internal environments makes sense. I don't remember if the docs make a distinction between internal and other environments.

warsaw avatar Dec 01 '25 03:12 warsaw