poetry: poetry install --extras doesn't work

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

The docs show a pyproject.toml:

[tool.poetry]
name = "awesome"

[tool.poetry.dependencies]
# These packages are mandatory and form the core of this package’s distribution.
mandatory = "^1.0"

# A list of all of the optional dependencies, some of which are included in the
# below `extras`. They can be opted into by apps.
psycopg2 = { version = "^2.7", optional = true }
mysqlclient = { version = "^1.3", optional = true }

[tool.poetry.extras]
mysql = ["mysqlclient"]
pgsql = ["psycopg2"]

And then an example of installing the “extras”:

poetry install --extras "mysql pgsql"

But pasting the relevant part of this example into my own pyproject.toml (see gist) it doesn’t work:

$ poetry install --extras "mysql pgsql"
Installing dependencies from lock file

[ValueError]
Extra [mysql] is not specified.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 26
  • Comments: 19 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Looks like you can install multiple dependencies in a single set using the following approach:

poetry add -E api fastapi
poetry add -E api gunicorn
poetry add -E api uvicorn

resulting in the following changes to the pyproject.toml file:

fastapi = {version = "^0.61.0", extras = ["api"]}
gunicorn = {version = "^20.0.4", extras = ["api"]}
uvicorn = {version = "^0.11.8", extras = ["api"]}

But running poetry update; poetry install -E API doesn’t work yet.

You need to add the following entry to the pyproject.toml file (NOTE you have to add the requirements specifier otherwise what gets passed to pip install complains and errors out):

[tool.poetry.extras]
api = ["fastapi^0.61.0", "gunicorn^20.0.4", "uvicorn^0.11.8"]

and then poetry update; poetry install -E API works fine.

My django-getpaid project has a test extra dependency group declared among others.

poetry install does not install pytest

poetry install -E test does not install pytest either.

I highly recommend writing extras syntax like this:

[tool.poetry.extras.full]

django-extensions = {version = "^3.1.3" }
drf-yasg = {version = "^1.20.0"}

Any progress on this bug? It’s a blocker.