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

Crash with "too many values to unpack" when adding package with poetry init #7567

Closed
4 tasks done
ssteinerx opened this issue Feb 27, 2023 · 2 comments · Fixed by #7569
Closed
4 tasks done

Crash with "too many values to unpack" when adding package with poetry init #7567

ssteinerx opened this issue Feb 27, 2023 · 2 comments · Fixed by #7569
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@ssteinerx
Copy link

ssteinerx commented Feb 27, 2023

  • Poetry version: 1.3.2
  • Python version: 3.11.2
  • OS version and name: Ubuntu 22.10
  • pyproject.toml: not created, crash
  • 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.
Package to add or search for (leave blank to skip): now we crash
Invalid package definition.

Package to add or search for (leave blank to skip): maybe now
Adding maybe now

Add a package (leave blank to skip): how about this

  Stack trace:

  12  .venv/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

  11  .venv/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│ 

  10  .venv/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│ 

   9  .venv/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

   8  .venv/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

   7  .venv/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:

   6  .venv/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

   5  .venv/lib/python3.11/site-packages/poetry/console/commands/init.py:198 in handle
       196│                 help_displayed = True
       197│             requirements.update(
     → 198│                 self._format_requirements(self._determine_requirements([]))
       199│             )
       200│             if self.io.is_interactive():

   4  .venv/lib/python3.11/site-packages/poetry/console/commands/init.py:287 in _determine_requirements
       285│             package = self.ask(question)
       286│             while package:
     → 287│                 constraint = self._parse_requirements([package])[0]
       288│                 if (
       289│                     "git" in constraint

   3  .venv/lib/python3.11/site-packages/poetry/console/commands/init.py:426 in _parse_requirements
       424│             cwd = Path.cwd()
       425│ 
     → 426│         return [
       427│             parse_dependency_specification(
       428│                 requirement=requirement,

   2  .venv/lib/python3.11/site-packages/poetry/console/commands/init.py:427 in <listcomp>
       425│ 
       426│         return [
     → 427│             parse_dependency_specification(
       428│                 requirement=requirement,
       429│                 env=self.env if isinstance(self, EnvCommand) else None,

   1  .venv/lib/python3.11/site-packages/poetry/utils/dependency_specification.py:218 in parse_dependency_specification
       216│         _parse_dependency_specification_url(requirement, env=env)
       217│         or _parse_dependency_specification_path(requirement, cwd=cwd)
     → 218│         or _parse_dependency_specification_simple(requirement)
       219│     )
       220│ 

  ValueError

  too many values to unpack (expected 2)

  at .venv/lib/python3.11/site-packages/poetry/utils/dependency_specification.py:117 in _parse_dependency_specification_simple
      113│ 
      114│     require: DependencySpec = {}
      115│ 
      116│     if " " in pair:
    → 117│         name, version = pair.split(" ", 2)
      118│         extras_m = re.search(r"\[([\w\d,-_]+)\]$", name)
      119│         if extras_m:
      120│             extras = [e.strip() for e in extras_m.group(1).split(",")]
      121│             name, _ = name.split("[")

Issue

Putting spaces in "Package to add or search for (leave blank to skip): prompt gives different results each time, the third time in a row it crashes.

Using a valid package on the first prompt causes a crash when spaces are used in response to the prompt the second time. I.E. respond with e.g. Django for the first package name, then now we crash for the second package name.

Unfortunately, Poetry just exits and does not write any of your prior responses anywhere so you're starting over next time.

@ssteinerx ssteinerx added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Feb 27, 2023
PabloEmidio added a commit to PabloEmidio/poetry that referenced this issue Mar 1, 2023
@PabloEmidio
Copy link
Contributor

Related #2554

PabloEmidio added a commit to PabloEmidio/poetry that referenced this issue Mar 1, 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
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants