Poetry removes it's own dependencies with `install --no-dev` when it manages the environment it is installed in
See original GitHub issue-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
Well… This issue is mentioned by @sontek in https://github.com/python-poetry/poetry/issues/3139#issuecomment-776355443_ but the response below advises to create a new issue, so here I am. -
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: Docker image based on
python:3.9.1
-
Poetry version: 1.1.6
-
Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/gbdlin/311dda3cd34672370cd97bf07f306a61
Issue
When you specify a package in the dev-dependencies
that is either a dependency of the poetry itself or it depends on one of the poetry dependencies, and you’ve installed poetry inside an environment that poetry is supposed to manage, poetry will uninstall this mentioned dependency after invoking poetry install --no-dev
, making itself unusable in the future.
I’m aware that it is advised to install poetry outside of the environment it should manage, but this is very often seen inside docker images (such example provided in the gist linked above) to save on the resources.
Example output presenting mentioned issue (without -vvv
ands):
$ pip install poetry
Requirement already satisfied: pip in /usr/local/lib/python3.9/site-packages (21.0.1)
Collecting poetry
Downloading poetry-1.1.6-py2.py3-none-any.whl (172 kB)
[ ... 70 irrelevant output lines truncated ... ]
Collecting appdirs<2,>=1.4.3
Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Installing collected packages: [ ... ] appdirs, [ ... ] poetry
Successfully installed [ ... ] appdirs-1.4.4 [ ... ] poetry-1.1.6 [ ... ]
$ poetry config virtualenvs.create false && poetry install --no-dev
Skipping virtualenv creation, as specified in config file.
Installing dependencies from lock file
Package operations: 0 installs, 0 updates, 1 removal
• Removing appdirs (1.4.4)
Removing intermediate container af920367a74d
As you can see, appdirs
, which is required by the poetry, was uninstalled by poetry. Full log, with the -vvv
and the attempt to run poetry again, available here
Issue Analytics
- State:
- Created 2 years ago
- Reactions:18
- Comments:11 (4 by maintainers)
If this is expected, it’s for sure not documented properly. Both in the documentation and when just using
poetry install --help
, the--no-dev
option is described asDo not install the development dependencies.
, notGet rid of the development dependencies
. There is also a 2nd command line options--remove-untracked
, from which I would expect to remove some dependencies.But even if the
--no-dev
’s expected behavior is to remove all dev dependencies, poetry should do one of those:This has change with poetry 1.2.0a2: Poetry wan’t remove installed packages unless the
--sync
option is given.However, if a dependency will be removed due to a version change e.g. on
poetry update
the package will be removed of course from the venv.fin swimmer