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 2 install command can not find pyproject.toml with --only and --directory parameters #9978

Open
konstantin-mueller opened this issue Jan 7, 2025 · 1 comment
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@konstantin-mueller
Copy link

Description

I have a pyproject.toml with package-mode = false and I'm copying it into a docker image. I installed the dependencies like this in previous versions of poetry:

poetry install --only main --no-cache -C /tmp

/tmp contains the pyproject.toml and poetry.lock files.

The command fails with poetry 2. Error message:

Poetry could not find a pyproject.toml file in / or its parents

The current directory during docker build is /. Poetry should change the directory to /tmp because of the -C /tmp parameter.

If I change the order of the parameters like this:

poetry install -C /tmp --only main --no-cache

then poetry successfully installs the dependencies.

Workarounds

Specify -C parameter before the --only parameter

Poetry Installation Method

pip

Operating System

Alpine 3.21

Poetry Version

2.0.0

Poetry Configuration

cache-dir = "/home/user/.cache/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/user/.cache/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

No response

Example pyproject.toml

No response

Poetry Runtime Logs

Stack trace:

  12  /opt/doc_venv/lib/python3.13/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

  11  /opt/doc_venv/lib/python3.13/site-packages/poetry/console/application.py:236 in _run
       234│ 
       235│         with directory(self._working_directory):
     → 236│             exit_code: int = super()._run(io)
       237│ 
       238│         return exit_code

  10  /opt/doc_venv/lib/python3.13/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│ 

   9  /opt/doc_venv/lib/python3.13/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

   8  /opt/doc_venv/lib/python3.13/site-packages/cleo/application.py:454 in _run_command
       452│ 
       453│         try:
     → 454│             self._event_dispatcher.dispatch(command_event, COMMAND)
       455│ 
       456│             if command_event.command_should_run():

   7  /opt/doc_venv/lib/python3.13/site-packages/cleo/events/event_dispatcher.py:26 in dispatch
        24│ 
        25│         if listeners:
     →  26│             self._do_dispatch(listeners, event_name, event)
        27│ 
        28│         return event

   6  /opt/doc_venv/lib/python3.13/site-packages/cleo/events/event_dispatcher.py:85 in _do_dispatch
        83│                 break
        84│ 
     →  85│             listener(event, event_name, self)
        86│ 
        87│     def _sort_listeners(self, event_name: str) -> None:

   5  /opt/doc_venv/lib/python3.13/site-packages/poetry/console/application.py:343 in configure_env
       341│ 
       342│         io = event.io
     → 343│         poetry = command.poetry
       344│ 
       345│         env_manager = EnvManager(poetry, io=io)

   4  /opt/doc_venv/lib/python3.13/site-packages/poetry/console/commands/command.py:24 in poetry
        22│     def poetry(self) -> Poetry:
        23│         if self._poetry is None:
     →  24│             return self.get_application().poetry
        25│ 
        26│         return self._poetry

   3  /opt/doc_venv/lib/python3.13/site-packages/poetry/console/application.py:181 in poetry
       179│             return self._poetry
       180│ 
     → 181│         self._poetry = Factory().create_poetry(
       182│             cwd=self._project_directory,
       183│             io=self._io,

   2  /opt/doc_venv/lib/python3.13/site-packages/poetry/factory.py:60 in create_poetry
        58│             io = NullIO()
        59│ 
     →  60│         base_poetry = super().create_poetry(cwd=cwd, with_groups=with_groups)
        61│ 
        62│         if version_str := base_poetry.local_config.get("requires-poetry"):

   1  /opt/doc_venv/lib/python3.13/site-packages/poetry/core/factory.py:48 in create_poetry
        46│         from poetry.core.pyproject.toml import PyProjectTOML
        47│ 
     →  48│         poetry_file = self.locate(cwd)
        49│         pyproject = PyProjectTOML(path=poetry_file)
        50│ 

  RuntimeError

  Poetry could not find a pyproject.toml file in / or its parents

  at /opt/doc_venv/lib/python3.13/site-packages/poetry/core/factory.py:802 in locate
      798│             if poetry_file.exists():
      799│                 return poetry_file
      800│ 
      801│         else:
    → 802│             raise RuntimeError(
      803│                 f"Poetry could not find a pyproject.toml file in {cwd} or its parents"
      804│             )
      805│
@konstantin-mueller konstantin-mueller added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jan 7, 2025
@dimbleby
Copy link
Contributor

dimbleby commented Jan 7, 2025

Probably belongs in cleo, not here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants