{"id":"9a5f643f25a8e291","repo":"python-poetry/poetry","slug":"pyproject-toml-changed-significantly-since-poetry","errorCode":null,"errorMessage":"pyproject.toml changed significantly since poetry.lock was last generated. Run `{self._lock_fix_command()}` to fix the lock file.","messagePattern":"pyproject\\.toml changed significantly since poetry\\.lock was last generated\\. Run `(.+?)` to fix the lock file\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/poetry/installation/installer.py","lineNumber":268,"sourceCode":"            ):\n                solved_packages = solver.solve(\n                    use_latest=self._whitelist\n                ).get_solved_packages()\n\n            if not self.executor.enabled:\n                # If we are only in lock mode, no need to go any further\n                self._write_lock_file(solved_packages)\n                return 0\n\n            for package in solved_packages:\n                if not lockfile_repo.has_package(package):\n                    lockfile_repo.add_package(package)\n\n        else:\n            self._io.write_line(\"<info>Installing dependencies from lock file</>\")\n\n            if not self._locker.is_fresh():\n                raise ValueError(\n                    \"pyproject.toml changed significantly since poetry.lock was last\"\n                    f\" generated. Run `{self._lock_fix_command()}` to fix the lock file.\"\n                )\n            if not (reresolve or self._locker.is_locked_groups_and_markers()):\n                if self._io.is_verbose():\n                    self._io.write_line(\n                        \"<info>Cannot install without re-resolving\"\n                        \" because the lock file is not at least version 2.1</>\"\n                    )\n                reresolve = True\n\n            locker_extras = {\n                canonicalize_name(extra)\n                for extra in self._locker.lock_data.get(\"extras\", {})\n            }\n            for extra in self._extras:\n                if extra not in locker_extras:\n                    raise ValueError(f\"Extra [{extra}] is not specified.\")","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/installation/installer.py#L250-L286","documentation":"Raised by Installer._do_install at src/poetry/installation/installer.py:267-271 when self._locker.is_fresh() returns False during a non-update install. Poetry detects that pyproject.toml's content hash no longer matches the one recorded in poetry.lock, meaning dependencies changed without re-locking. ValueError; the message includes the exact command to run.","triggerScenarios":"Editing [tool.poetry.dependencies] (or any section that affects the lock's content hash) and then running `poetry install` without `poetry lock` first. Reached in the else branch of _do_install (the install-from-lock path).","commonSituations":"Adding/removing a dependency in pyproject.toml via editor instead of `poetry add/remove`, merging a branch that changed dependencies, or a teammate's commit that updated pyproject.toml but not poetry.lock.","solutions":["Run the exact command printed in the message (usually `poetry lock --no-update`) to refresh poetry.lock while keeping versions.","If the lock is badly out of date, run `poetry lock` to fully re-resolve.","Commit the regenerated poetry.lock alongside the pyproject.toml change."],"exampleFix":"# before\n$ poetry install\nValueError: pyproject.toml changed significantly since poetry.lock ... Run `poetry lock --no-update` ...\n\n# after\n$ poetry lock --no-update\n$ poetry install","handlingStrategy":"validation","validationCode":"from poetry.packages.locker import Locker\n\nlocker = Locker(local_lock, pyproject_data)\nif not locker.is_fresh():\n    raise SystemExit(\n        'pyproject.toml out of sync with poetry.lock; run `poetry lock --no-update` first.'\n    )","typeGuard":null,"tryCatchPattern":"try:\n    installer.run()\nexcept ValueError as e:\n    if 'pyproject.toml changed significantly' in str(e):\n        import subprocess\n        subprocess.run(['poetry', 'lock', '--no-update'], check=True)\n        installer.run()\n    raise","preventionTips":["Always commit poetry.lock together with pyproject.toml dependency changes.","Use `poetry add`/`poetry remove` instead of editing dependencies by hand."],"tags":["lock-file","pyproject","installer","validation"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}