v5.1 breaks hatch
Hi,
it seems the latest release 5.1
introduced unconditional print statements which may not be the best idea Claude ever had and also has hatch
trip when trying to create venvs.
To reproduce this I created a fresh hatch
project, added pip-system-certs
as dependency and ran:
hatch env create
That results in this error:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/hatch/cli/__init__.py:221 │
│ in main │
│ │
│ 218 │
│ 219 def main(): # no cov │
│ 220 │ try: │
│ ❱ 221 │ │ hatch(prog_name='hatch', windows_expand_args=False) │
│ 222 │ except Exception: # noqa: BLE001 │
│ 223 │ │ import sys │
│ 224 │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/click/core.py:1161 in │
│ __call__ │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/click/core.py:1082 in │
│ main │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/click/core.py:1697 in │
│ invoke │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/click/core.py:1697 in │
│ invoke │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/click/core.py:1443 in │
│ invoke │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/click/core.py:788 in │
│ invoke │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/click/decorators.py:45 in │
│ new_func │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/hatch/cli/env/create.py:3 │
│ 8 in create │
│ │
│ 35 │ │ │ │
│ 36 │ │ │ app.abort(f'Environment `{env}` is incompatible: {e}') │
│ 37 │ │ │
│ ❱ 38 │ │ app.prepare_environment(environment) │
│ 39 │ │
│ 40 │ if incompatible: │
│ 41 │ │ num_incompatible = len(incompatible) │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/hatch/cli/application.py: │
│ 148 in prepare_environment │
│ │
│ 145 │ │ current_dep_hash = self.env_metadata.dependency_hash(environment) │
│ 146 │ │ if new_dep_hash != current_dep_hash: │
│ 147 │ │ │ with environment.app_status_dependency_installation_check(): │
│ ❱ 148 │ │ │ │ dependencies_in_sync = environment.dependencies_in_sync() │
│ 149 │ │ │ │
│ 150 │ │ │ if not dependencies_in_sync: │
│ 151 │ │ │ │ with environment.app_status_dependency_synchronization(): │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/hatch/env/virtual.py:191 │
│ in dependencies_in_sync │
│ │
│ 188 │ │ │
│ 189 │ │ with self.safe_activation(): │
│ 190 │ │ │ return dependencies_in_sync( │
│ ❱ 191 │ │ │ │ self.dependencies_complex, sys_path=self.virtual_env.sys_path, environme │
│ 192 │ │ │ ) │
│ 193 │ │
│ 194 │ def sync_dependencies(self): │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/hatch/venv/core.py:101 in │
│ sys_path │
│ │
│ 98 │ │
│ 99 │ @property │
│ 100 │ def sys_path(self): │
│ ❱ 101 │ │ return self.python_info.sys_path │
│ 102 │ │
│ 103 │ def __enter__(self): │
│ 104 │ │ self.activate() │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/hatch/utils/env.py:40 in │
│ sys_path │
│ │
│ 37 │ @property │
│ 38 │ def sys_path(self) -> list[str]: │
│ 39 │ │ if self.__sys_path is None: │
│ ❱ 40 │ │ │ self.__sys_path = self.dep_check_data['sys_path'] │
│ 41 │ │ │
│ 42 │ │ return self.__sys_path │
│ 43 │
│ │
│ /home/wsluser/.local/share/uv/tools/hatch/lib/python3.12/site-packages/hatch/utils/env.py:26 in │
│ dep_check_data │
│ │
│ 23 │ │ │ │ [self.executable, '-W', 'ignore', '-'], capture_output=True, input=DEP_C │
│ 24 │ │ │ ) │
│ 25 │ │ │ │
│ ❱ 26 │ │ │ self.__dep_check_data = literal_eval(process.stdout.strip().decode('utf-8')) │
│ 27 │ │ │
│ 28 │ │ return self.__dep_check_data │
│ 29 │
│ │
│ /usr/lib/python3.12/ast.py:66 in literal_eval │
│ │
│ 63 │ Caution: A complex expression can overflow the C stack and cause a crash. │
│ 64 │ """ │
│ 65 │ if isinstance(node_or_string, str): │
│ ❱ 66 │ │ node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval') │
│ 67 │ if isinstance(node_or_string, Expression): │
│ 68 │ │ node_or_string = node_or_string.body │
│ 69 │ def _raise_malformed_node(node): │
│ │
│ /usr/lib/python3.12/ast.py:52 in parse │
│ │
│ 49 │ │ │ raise ValueError(f"Unsupported major version: {major}") │
│ 50 │ │ feature_version = minor │
│ 51 │ # Else it should be an int giving the minor version for 3.x. │
│ ❱ 52 │ return compile(source, filename, mode, flags, │
│ 53 │ │ │ │ _feature_version=feature_version) │
│ 54 │
│ 55 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ pip_system_certs: using pip's vendored truststore │
│ ▲ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
SyntaxError: unterminated string literal (detected at line 1)
After patching out the print statements, hatch
had no problems creating the env.