diff --git a/src/poetry/console/application.py b/src/poetry/console/application.py index c038db7f02b..c8bb3452cee 100644 --- a/src/poetry/console/application.py +++ b/src/poetry/console/application.py @@ -362,6 +362,7 @@ def _default_definition(self) -> Definition: description=( "The working directory for the Poetry command (defaults to the" " current working directory)." + " The Poetry project will be selected automatically using this path" ), ) ) @@ -371,7 +372,11 @@ def _default_definition(self) -> Definition: @cached_property def _directory(self) -> Path: if self._io and self._io.input.option("directory"): - return Path(self._io.input.option("directory")).absolute() + path = Path(self._io.input.option("directory")).absolute() + if not (path / "pyproject.toml").exists(): + raise ValueError(f"Could not find a project in directory {path}") + return path + return Path.cwd()