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

Improve 'poetry add x y z' behavior when either x, y or z are already installed. #1925

Closed
2 tasks done
mbello opened this issue Jan 21, 2020 · 3 comments
Closed
2 tasks done
Labels
kind/feature Feature requests/implementations

Comments

@mbello
Copy link

mbello commented Jan 21, 2020

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

The command poetry add x fails with an error if x is already installed. It is common to write scripts where one issues the full command e.g. 'apt-get install --y x y z' when you want to make sure x, y and z are installed without first checking whether any of those pieces are already present in the system. Similarly, I would like my script to not abort because poetry errors out when I ask it to add a package that is already installed.
Worse yet, when issuing poetry add x y z, if x is already installed, it will fail before installing y and z so it is not even possible to just ignore the error.

Possible solution 1: make poetry ignore installed packages, just issue a warning in those cases and then skip to the next package that needs to be added.

Possible solution 2: to avoid changing behavior in these cases (which I do not think would be a big deal), add a command switch to enable this desirable behavior

@mbello mbello added the kind/feature Feature requests/implementations label Jan 21, 2020
@mbello mbello changed the title Improve 'poetry add x y z' behavior when x, y or z are already installed. Improve 'poetry add x y z' behavior when either x, y or z are already installed. Jan 21, 2020
@seansfkelley
Copy link

seansfkelley commented Feb 20, 2020

FWIW, Yarn treats adding a package you already have the same as adding it anew: it sets the declared version range in package.json (i.e., pyproject.toml) to match at least the latest available version, then re-resolves and re-locks. I quite like this behavior, and often do poetry add by accident.

Edit: that said, apparently the docs already have an answer for this:

If you try to add a package that is already present, you will get an error. However, if you specify a constraint, like above, the dependency will be updated by using the specified constraint. If you want to get the latest version of an already present dependency you can use the special latest constraint:

@finswimmer
Copy link
Member

This was implemented in #2886

Copy link

github-actions bot commented Mar 2, 2024

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 Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Feature requests/implementations
Projects
None yet
Development

No branches or pull requests

3 participants