question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Poetry install no longer removes dev dependencies

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.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: MacOS
  • Poetry version: 0.12.2

Issue


There is currently no way to go from a develop poetry install to one that has --no-dev.

In previous versions, if you ran poetry install --no-dev it would remove all dev dependencies from the current virtual environment.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

11reactions
goosemocommented, Apr 29, 2019

This behavior seems like a bug, especially in how --no-dev is documented.

–no-dev: Do not install dev dependencies

This doesn’t state that poetry will uninstall anything. Can this be addressed with docs and perhaps a flag or configuration to not have this behavior happen?

My use case for example is to not have poetry uninstall every python package I have installed inside a docker container, or a developer machine, when it is configured to not use virtualenvs.

7reactions
owaiscommented, Mar 19, 2021

This is quite a big pain point actually. It’d be nice to at least have a flag to turn this behavior off. Here is how I’m trying using it.

I’m working on a library say LibA and I need to manually test it in multiple apps during development. From docs and poetry install --help, it seems poetry install --no-dev is the exactly what I need because of:

  --no-dev               Do not install the development dependencies.

Intuitively, I felt I’d do the following:

# currently in my poetry managed LibA project
> pwd
~/LibA

# activate my test app's venv
. ~/app/venv/bin/activate

# install LibA as an editable package in app's env
poetry install --no-dev

This installs LibA as an editable install in app’s venv. Now I should be able to run the app, make changes to LibA and have them reflect in the app without having to re-install LibA after every change.

However, this doesn’t work exactly as expected. When poetry install is executed with the --no-dev option, it looks up for all dev dependencies of LibA and uninstalls them from app’s env. This is a huge issue if app has any packages in common with LibA’s dev dependencies. What makes it even worse is that poetry removes even indirect dependencies which makes it very likely for the deps to match.

I feel the default behavior should be to not install dev dependencies when --no-dev is passed (as it is documented) and to not remove any packages at all. If that is not desirable for some reason, we should be able to pass in another CLI param that prevents poetry from removing packages. Something like poetry install --no-dev --no-remove.

BTW what use cases demand that dev packages get removed when --no-dev is passed? Poetry already spports a --remove-untracked option. May be if a user wants to remove dev deps, they can run poetry install --no-dev --remove-untracked and this would ensure any dev deps are uninstalled. poetry install --no-dev would only install packages and never remove anything.

Question: Is there another ideal way to work with the workflow that I described above when using poetry?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Commands | Documentation | Poetry - Python dependency ...
--no-dev : Do not install dev dependencies. (Deprecated, use --without dev or --only main instead); --remove-untracked : Remove dependencies not presented ...
Read more >
python - poetry: no way exclude dependencies for production?
Dev dependencies don't get installed when you do a normal poetry install . Do you have some reason to think it would be...
Read more >
Dependency Management With Python Poetry
When you add a requirement to the pyproject.toml file, it's not installed yet. As long as there's no poetry.lock file present in your...
Read more >
Add ability to optionally ignore dev dependencies in Poetry ...
When Dependency Scanning runs on Poetry projects, it will always include development dependencies. NPM projects with dependency scanning respect ...
Read more >
A Poetic Apology. Or Why Should You Use Poetry to Manage…
lock file already exists, if you now run poetry install then Poetry will resolve and install dependencies using the versions specified in such...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found