Skip to content

Implicit main dependency group does not exist when specifying project.dependencies = [] #10557

@bkeryan

Description

@bkeryan

Description

I have a project with no direct dependencies. Its build workflows and ReadTheDocs config use poetry install --only main,docs. Migrating the empty tool.poetry.dependencies to project.dependencies = [] causes poetry install --only main,docs to error:

Group(s) not found: main (via --only)

The attached pyproject.toml reproduces this behavior with the command poetry install --only main (no other dependency groups needed).

Workarounds

Continue to use tool.poetry.dependencies:

[project]
...
dynamic = ["dependencies"]

[tool.poetry.dependencies]

Or create an explicit "main" dependency group:

[tool.poetry.group.main.dependencies]

Or update all poetry install --only main commands.

Poetry Installation Method

pipx

Operating System

Windows 11

Poetry Version

Poetry (version 2.2.0)

Poetry Configuration

cache-dir = "C:\\Users\\bkeryan\\AppData\\Local\\pypoetry\\Cache"
data-dir = "C:\\Users\\bkeryan\\AppData\\Roaming\\pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
python.installation-dir = "{data-dir}\\python"  # C:\Users\bkeryan\AppData\Roaming\pypoetry\python
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"  # C:\Users\bkeryan\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

sysconfig.log
Platform: "win-amd64"
Python version: "3.11"
Current installation scheme: "nt"

Paths:
      data = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9"
      include = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9\Include"
      platinclude = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9\Include"
      platlib = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9\Lib\site-packages"
      platstdlib = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9\Lib"
      purelib = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9\Lib\site-packages"
      scripts = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9\Scripts"
      stdlib = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9\Lib"

Variables:
      BINDIR = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9"
      BINLIBDEST = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9\Lib"
      EXE = ".exe"
      EXT_SUFFIX = ".cp311-win_amd64.pyd"
      INCLUDEPY = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9\Include"
      LIBDEST = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9\Lib"
      TZPATH = ""
      VERSION = "311"
      VPATH = "..\.."
      abiflags = ""
      base = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9"
      exec_prefix = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9"
      installed_base = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9"
      installed_platbase = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9"
      platbase = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9"
      platlibdir = "DLLs"
      prefix = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9"
      projectbase = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9"
      py_version = "3.11.9"
      py_version_nodot = "311"
      py_version_nodot_plat = "311"
      py_version_short = "3.11"
      srcdir = "C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9"
      userbase = "C:\Users\bkeryan\AppData\Roaming\Python"

Example pyproject.toml

[project]
name = "testproj2"
version = "0.1.0"
description = ""
authors = []
readme = "README.md"
requires-python = ">=3.11"
dependencies = []

[tool.poetry]
packages = [{include = "testproj2", from = "src"}]

[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"

Poetry Runtime Logs

poetry-runtime.log
Loading configuration file C:\Users\bkeryan\AppData\Roaming\pypoetry\config.toml
[findpython:findpython] Running script: ['C:\\Users\\bkeryan\\.pyenv\\pyenv-win\\shims\\python.BAT', '-EsSc', 'import sys; print(sys.executable)']
Found: C:\Users\bkeryan\.pyenv\pyenv-win\versions\3.11.9\python.exe
[findpython:findpython] Running script: ['C:\\Users\\bkeryan\\.pyenv\\pyenv-win\\shims\\python.BAT', '-EsSc', 'import platform; print(platform.python_version())']
Using virtualenv: C:\Users\bkeryan\AppData\Local\pypoetry\Cache\virtualenvs\testproj2-dwLYvCK1-py3.11
Checking keyring availability: Checking if keyring is available
[keyring:keyring.backend] Loading KWallet
[keyring:keyring.backend] Loading SecretService
[keyring:keyring.backend] Loading Windows
[win32ctypes:win32ctypes.core.ctypes] Loaded ctypes backend
[keyring:keyring.backend] Loading chainer
[keyring:keyring.backend] Loading libsecret
[keyring:keyring.backend] Loading macOS
Using keyring backend 'Windows WinVaultKeyring'
Available

Stack trace:

11  ~\pipx\venvs\poetry2-2-0\Lib\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

10  ~\pipx\venvs\poetry2-2-0\Lib\site-packages\poetry\console\application.py:260 in _run
     258│
     259│             try:
   → 260│                 exit_code = super()._run(io)
     261│             except PoetryRuntimeError as e:
     262│                 io.write_error_line("")

 9  ~\pipx\venvs\poetry2-2-0\Lib\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│

 8  ~\pipx\venvs\poetry2-2-0\Lib\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

 7  ~\pipx\venvs\poetry2-2-0\Lib\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

 6  ~\pipx\venvs\poetry2-2-0\Lib\site-packages\cleo\commands\base_command.py:117 in run
     115│         io.input.validate()
     116│
   → 117│         return self.execute(io) or 0
     118│
     119│     def merge_application_definition(self, merge_args: bool = True) -> None:

 5  ~\pipx\venvs\poetry2-2-0\Lib\site-packages\poetry\console\commands\installer_command.py:39 in execute
      37│     def execute(self, io: IO) -> int:
      38│         PoetryKeyring.preflight_check(io, self.poetry.config)
   →  39│         return super().execute(io)
      40│

 4  ~\pipx\venvs\poetry2-2-0\Lib\site-packages\cleo\commands\command.py:61 in execute
      59│
      60│         try:
   →  61│             return self.handle()
      62│         except KeyboardInterrupt:
      63│             return 1

 3  ~\pipx\venvs\poetry2-2-0\Lib\site-packages\poetry\console\commands\install.py:167 in handle
     165│         self.installer.extras(extras)
     166│
   → 167│         self.installer.only_groups(self.activated_groups)
     168│         self.installer.skip_directory(self.option("no-directory"))
     169│         self.installer.dry_run(self.option("dry-run"))

 2  ~\pipx\venvs\poetry2-2-0\Lib\site-packages\poetry\console\commands\install.py:91 in activated_groups
      89│             return set()
      90│         else:
   →  91│             return super().activated_groups
      92│
      93│     @property

 1  ~\pipx\venvs\poetry2-2-0\Lib\site-packages\poetry\console\commands\group_command.py:90 in activated_groups
      88│             )
      89│
   →  90│         self._validate_group_options(groups)
      91│
      92│         if groups["only"] and (groups["with"] or groups["without"]):

GroupNotFoundError

Group(s) not found: main (via --only)

at ~\pipx\venvs\poetry2-2-0\Lib\site-packages\poetry\console\commands\group_command.py:134 in _validate_group_options
    130│                     f"--{opt}"
    131│                     for opt in sorted(invalid_options[group])
    132│                 )
    133│                 message_parts.append(f"{group} (via {opts})")
  → 134│             raise GroupNotFoundError(f"Group(s) not found: {', '.join(message_parts)}")
    135│

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreRelated to the poetry-core librarykind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions