{"id":"48b4d4a8f314c90c","repo":"python-poetry/poetry","slug":"the-lock-file-is-not-compatible-with-the-current-v","errorCode":null,"errorMessage":"The lock file is not compatible with the current version of Poetry.\nRegenerate the lock file with the `poetry lock` command.","messagePattern":"The lock file is not compatible with the current version of Poetry\\.\nRegenerate the lock file with the `poetry lock` command\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/poetry/packages/locker.py","lineNumber":363,"sourceCode":"            raise RuntimeError(\"No lockfile found. Unable to read locked packages\")\n\n        with self.lock.open(\"rb\") as f:\n            try:\n                lock_data = tomllib.load(f)\n            except tomllib.TOMLDecodeError as e:\n                raise RuntimeError(f\"Unable to read the lock file ({e}).\")\n\n        # if the lockfile doesn't contain a metadata section at all,\n        # it probably needs to be rebuilt completely\n        if \"metadata\" not in lock_data:\n            raise RuntimeError(\n                \"The lock file does not have a metadata entry.\\n\"\n                \"Regenerate the lock file with the `poetry lock` command.\"\n            )\n\n        metadata = lock_data[\"metadata\"]\n        if \"lock-version\" not in metadata:\n            raise RuntimeError(\n                \"The lock file is not compatible with the current version of Poetry.\\n\"\n                \"Regenerate the lock file with the `poetry lock` command.\"\n            )\n        lock_version = Version.parse(metadata[\"lock-version\"])\n        current_version = Version.parse(self._VERSION)\n        accepted_versions = parse_constraint(self._READ_VERSION_RANGE)\n        lock_version_allowed = accepted_versions.allows(lock_version)\n        if lock_version_allowed and current_version < lock_version:\n            logger.warning(\n                \"The lock file might not be compatible with the current version of\"\n                \" Poetry.\\nUpgrade Poetry to ensure the lock file is read properly or,\"\n                \" alternatively, regenerate the lock file with the `poetry lock`\"\n                \" command.\"\n            )\n        elif not lock_version_allowed:\n            raise RuntimeError(\n                \"The lock file is not compatible with the current version of Poetry.\\n\"\n                \"Upgrade Poetry to be able to read the lock file or, alternatively, \"","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/packages/locker.py#L345-L381","documentation":"Raised by Locker._get_lock_data() when the lockfile has a [metadata] table but that table lacks the 'lock-version' field. lock-version is how Poetry negotiates schema compatibility; without it the file is treated as an unrecognised/legacy format. The message directs the user to regenerate.","triggerScenarios":"A poetry.lock whose [metadata] table exists (so error 62 is bypassed) but was authored without the lock-version key — typically an old-format lockfile or one edited to remove the field. Triggered by install/show/update --lock.","commonSituations":"Lockfile produced by Poetry 1.x early schema before lock-version was standardised; manual deletion of the lock-version line; a partial write that truncated the metadata table.","solutions":["Run `poetry lock` to rewrite poetry.lock with the current schema including lock-version.","Upgrade Poetry (`poetry self update`) so the regenerated lockfile uses the latest lock-version.","If preserving pins matters, run `poetry lock --no-update` to re-emit metadata without re-resolving."],"exampleFix":"// before: [metadata] without lock-version\n[metadata]\ncontent-hash = \"abc123\"\n\n// after\n$ poetry lock --no-update\n# produces:\n# [metadata]\n# lock-version = \"2.1\"\n# python-versions = \">=3.9\"\n# content-hash = \"abc123\"","handlingStrategy":"validation","validationCode":"import tomllib\nfrom pathlib import Path\n\ndef lockfile_has_lock_version(path: Path) -> bool:\n    with path.open(\"rb\") as f:\n        data = tomllib.load(f)\n    return \"lock-version\" in data.get(\"metadata\", {})","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a recent stable Poetry to generate lockfiles.","Run `poetry lock --no-update` after upgrading Poetry to refresh metadata without re-resolving.","Add a CI check asserting metadata.lock-version is present.","Educate the team not to strip metadata fields when editing."],"tags":["lockfile","version","compatibility"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}