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

Unhelpful errors for projects in root directory #7185

Open
4 tasks done
brandon-leapyear opened this issue Dec 12, 2022 · 3 comments
Open
4 tasks done

Unhelpful errors for projects in root directory #7185

brandon-leapyear opened this issue Dec 12, 2022 · 3 comments
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@brandon-leapyear
Copy link

brandon-leapyear commented Dec 12, 2022

  • Poetry version: 1.3.1
  • Python version: 3.11
  • OS version and name: ubuntu
  • pyproject.toml: see below
  • I am on the latest stable Poetry version, installed using a recommended method.
  • 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

Repro: running docker build . with this Dockerfile shows an unhelpful "tuple index out of range" error:

FROM python:3.11

RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH=/root/.local/bin:$PATH
RUN poetry --version
RUN poetry init
RUN poetry install

Seems to happen when packages is not specified in pyproject.toml and poetry tries to automatically add an Include that has a glob pattern ., which is an invalid glob:

>>> list(Path("/").glob("."))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/pathlib.py", line 1139, in glob
    selector = _make_selector(tuple(pattern_parts), self._flavour)
  File "/usr/local/lib/python3.8/pathlib.py", line 463, in _make_selector
    pat = pattern_parts[0]
IndexError: tuple index out of range
@brandon-leapyear brandon-leapyear added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Dec 12, 2022
@brandon-leapyear brandon-leapyear changed the title Unhelpful "tuple index out of range" error on empty project Unhelpful errors for projects in root directory Dec 12, 2022
@brandon-leapyear
Copy link
Author

brandon-leapyear commented Dec 12, 2022

This is an old work account. Please reference @brandonchinn178 for all future communication


ah seems to only happen when running in the root directory / and without a name specified (as is the case with poetry init). So perhaps not high priority.

Also, there's another error when using poetry init --dependency=click in the root directory:

  Unable to parse fact: fact:  depends on click (^8.1.3)

  at ~/.local/share/pypoetry/venv/lib/python3.11/site-packages/poetry/puzzle/provider.py:840 in debug
       836│         if message.startswith("fact:"):
       837│             if "depends on" in message:
       838│                 m = re.match(r"fact: (.+?) depends on (.+?) \((.+?)\)", message)
       839│                 if m is None:
    →  840│                     raise ValueError(f"Unable to parse fact: {message}")
       841│                 m2 = re.match(r"(.+?) \((.+?)\)", m.group(1))
       842│                 if m2:
       843│                     name = m2.group(1)
       844│                     version = f" ({m2.group(2)})"

@silverwind
Copy link

silverwind commented Jun 18, 2023

Another way to reproduce tuple index out of range coming from pathlib is to run poetry on this pyproject.toml. See #8113 for full stack traces.

[tool.poetry]
name = ""
version = "0.0.0"
description = ""
authors = []

[tool.poetry.dependencies]
python = "^3.8"

@dimbleby
Copy link
Contributor

presumably can be fixed by adding a pattern to the schema, preventing empty strings - at https://github.com/python-poetry/poetry-core/blob/0749c5531d778a07788dfdc163716523fd479d9e/src/poetry/core/json/schemas/poetry-schema.json#L13

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

3 participants