Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poetry env info doesn't work if pyproject.toml contains path dependency to non existing local directory #7277

Closed
4 tasks done
ktetzlaff opened this issue Jan 2, 2023 · 2 comments
Labels
status/duplicate Duplicate issues

Comments

@ktetzlaff
Copy link

  • Poetry version: 1.3.1
  • Python version: 3.11.1
  • OS version and name: Debian bookworm (12)
  • pyproject.toml:
pyproject.toml
[tool.poetry]
name = "prj2"
version = "0.1.0"
description = ""
authors = ["<redacted>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
prj1 = {path = "../prj1"}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
  • I am on the latest stable Poetry version, installed using a recommended method (pipx).
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

pyproject.toml references a dependency with a relative path and the referenced directory has been removed (or renamed).

Now, running poetry env info results in error: Directory ... does not exist.

Reproduce with:

_tmp="$(mktemp -d)"
pushd "${_tmp}"
poetry new prj1
poetry new prj2
cd prj2
poetry add ../prj1
mv ../prj1 ../prj1.renamed

# poetry fails to show environment info
poetry env info -p
# => error: Directory ../prj1 does not exist

It should not be necessary to resolve dependencies just to get the environment info.

Output of poetry -vvv env info -p" ```log Stack trace:

15 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:327 in run
325│
326│ try:
→ 327│ exit_code = self._run(io)
328│ except BrokenPipeError:
329│ # If we are piped to another process, it may close early and send a

14 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/application.py:190 in _run
188│ self._load_plugins(io)
189│
→ 190│ exit_code: int = super()._run(io)
191│ return exit_code
192│

13 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:431 in _run
429│ io.input.interactive(interactive)
430│
→ 431│ exit_code = self._run_command(command, io)
432│ self._running_command = None
433│

12 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:473 in _run_command
471│
472│ if error is not None:
→ 473│ raise error
474│
475│ return terminate_event.exit_code

11 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:457 in _run_command
455│
456│ if command_event.command_should_run():
→ 457│ exit_code = command.run(io)
458│ else:
459│ exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

10 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/commands/base_command.py:119 in run
117│ io.input.validate()
118│
→ 119│ status_code = self.execute(io)
120│
121│ if status_code is None:

9 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/commands/command.py:62 in execute
60│
61│ try:
→ 62│ return self.handle()
63│ except KeyboardInterrupt:
64│ return 1

8 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/commands/env/info.py:23 in handle
21│ from poetry.utils.env import EnvManager
22│
→ 23│ env = EnvManager(self.poetry).get()
24│
25│ if self.option("path"):

7 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/commands/command.py:23 in poetry
21│ def poetry(self) -> Poetry:
22│ if self._poetry is None:
→ 23│ return self.get_application().poetry
24│
25│ return self._poetry

6 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/application.py:129 in poetry
127│ project_path = self._io.input.option("directory")
128│
→ 129│ self._poetry = Factory().create_poetry(
130│ cwd=project_path,
131│ io=self._io,

5 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/factory.py:55 in create_poetry
53│ io = NullIO()
54│
→ 55│ base_poetry = super().create_poetry(cwd=cwd, with_groups=with_groups)
56│
57│ locker = Locker(

4 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/factory.py:65 in create_poetry
63│ assert isinstance(version, str)
64│ package = self.get_package(name, version)
→ 65│ package = self.configure_package(
66│ package, local_config, poetry_file.parent, with_groups=with_groups
67│ )

3 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/factory.py:159 in configure_package
157│
158│ if "dependencies" in config:
→ 159│ cls._add_package_group_dependencies(
160│ package=package, group=MAIN_GROUP, dependencies=config["dependencies"]
161│ )

2 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/factory.py:105 in _add_package_group_dependencies
103│
104│ group.add_dependency(
→ 105│ cls.create_dependency(
106│ name,
107│ _constraint,

1 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/factory.py:317 in create_dependency
315│ )
316│ else:
→ 317│ dependency = DirectoryDependency(
318│ name,
319│ path,

ValueError

Directory ../prj1 does not exist

at ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/packages/directory_dependency.py:38 in init
34│
35│ self._develop = develop
36│
37│ if not self._full_path.exists():
→ 38│ raise ValueError(f"Directory {self._path} does not exist")
39│
40│ if self._full_path.is_file():
41│ raise ValueError(f"{self._path} is a file, expected a directory")
42│

</details>
@ktetzlaff ktetzlaff added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jan 2, 2023
@neersighted
Copy link
Member

More or less a duplicate of #668 as the same logic is causing this; this is just a non-install operation.

@neersighted neersighted closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2023
@neersighted neersighted added status/duplicate Duplicate issues and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jan 2, 2023
@ktetzlaff ktetzlaff changed the title poetry env info doesn't work if pyproject.toml contains reference to non existing local dependency poetry env info doesn't work if pyproject.toml contains path dependency to non existing local directory Jan 2, 2023
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/duplicate Duplicate issues
Projects
None yet
Development

No branches or pull requests

2 participants