diff --git a/src/poetry/console/commands/export.py b/src/poetry/console/commands/export.py
index 508502d84f6..5aae2f1017c 100644
--- a/src/poetry/console/commands/export.py
+++ b/src/poetry/console/commands/export.py
@@ -59,10 +59,9 @@ def handle(self) -> None:
if not locker.is_fresh():
self.line_error(
""
- "Warning: The lock file is not up to date with "
- "the latest changes in pyproject.toml. "
- "You may be getting outdated dependencies. "
- "Run update to update them."
+ "Warning: poetry.lock is not consistent with pyproject.toml. "
+ "You may be getting improper dependencies. "
+ "Run `poetry lock [--no-update]` to fix it."
""
)
diff --git a/src/poetry/console/commands/lock.py b/src/poetry/console/commands/lock.py
index 3eb9d26d810..0a9f83cfcb7 100644
--- a/src/poetry/console/commands/lock.py
+++ b/src/poetry/console/commands/lock.py
@@ -37,11 +37,16 @@ def handle(self) -> int:
)
if self.option("check"):
- return (
- 0
- if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh()
- else 1
+ if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh():
+ self.line("poetry.lock is consistent with pyproject.toml.")
+ return 0
+ self.line(
+ ""
+ "Error: poetry.lock is not consistent with pyproject.toml. "
+ "Run `poetry lock [--no-update]` to fix it."
+ ""
)
+ return 1
self._installer.lock(update=not self.option("no-update"))
diff --git a/src/poetry/installation/installer.py b/src/poetry/installation/installer.py
index 697c707b7f6..781cee08731 100644
--- a/src/poetry/installation/installer.py
+++ b/src/poetry/installation/installer.py
@@ -258,10 +258,9 @@ def _do_install(self, local_repo: Repository) -> int:
if not self._locker.is_fresh():
self._io.write_line(
""
- "Warning: The lock file is not up to date with "
- "the latest changes in pyproject.toml. "
- "You may be getting outdated dependencies. "
- "Run update to update them."
+ "Warning: poetry.lock is not consistent with pyproject.toml. "
+ "You may be getting improper dependencies. "
+ "Run `poetry lock [--no-update]` to fix it."
""
)
diff --git a/tests/console/commands/test_lock.py b/tests/console/commands/test_lock.py
index eb441bf6811..7bcf708de07 100644
--- a/tests/console/commands/test_lock.py
+++ b/tests/console/commands/test_lock.py
@@ -81,6 +81,12 @@ def test_lock_check_outdated(
tester = command_tester_factory("lock", poetry=poetry_with_outdated_lockfile)
status_code = tester.execute("--check")
+ expected = (
+ "Error: poetry.lock is not consistent with pyproject.toml. "
+ "Run `poetry lock [--no-update]` to fix it.\n"
+ )
+
+ assert tester.io.fetch_output() == expected
# exit with an error
assert status_code == 1
@@ -101,6 +107,8 @@ def test_lock_check_up_to_date(
tester = command_tester_factory("lock", poetry=poetry_with_up_to_date_lockfile)
status_code = tester.execute("--check")
+ expected = "poetry.lock is consistent with pyproject.toml.\n"
+ assert tester.io.fetch_output() == expected
# exit with an error
assert status_code == 0