hatch
hatch copied to clipboard
Unable to add script with `exec` keyword
I attempted to include a hatch run clean command in my pyproject.toml to clean up the __pycache__ directories as follows:
[tool.hatch.envs.default.scripts]
clean = [ "find . -type d -name '__pycache__' -exec rm -rf {} +" ]
Unfortunately, this command would consistently fail with the following error: tuple index out of range. I was able to get the command to run by changing it to the following:
[tool.hatch.envs.default.scripts]
clean = [ "find . -type d -name '__pycache__' | xargs rm -rf" ]
While this solution works, I don't see any specific documentation notating issues with including an exec keyword in user-defined scripts, so I suspect this is a bug.
Thank you!
Because of context formatting, your script should look like this instead, note the double curly braces.
[tool.hatch.envs.default.scripts]
clean = [ "find . -type d -name '__pycache__' -exec rm -rf {{}} +" ]