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.

Update the lock file without upgrading dependencies

See original GitHub issue
  • 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

Please provide a way to update the lock file without upgrading dependencies.

After adding a [tool.poetry.extras] section to pyproject.toml, Poetry displays the following warning, for example on install:

Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.

That’s fine, but if I run poetry update it upgrades my dependencies, which is not what I want at this time. If I run poetry lock instead, it still upgrades dependencies. Am I missing something?

Here are the relevant files and the commit:

Sorry for not providing a smaller reproducible example, it’s quite tricky to generate a poetry.lock file with outdated dependencies.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:51
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

27reactions
PavlosMelissinoscommented, Apr 27, 2020

This functionality is much needed imo. A single package addition/update shouldn’t trigger a dependency graph resolution for all the dependencies of the project.

I’d rather poetry lock/poetry update be more conservative by default. If we want to keep the current functionality as well, even though I consider auto-updates to be a bad practice, there could be an additional flag like --refresh to force irrelevant dependencies to update as well if there’s a newer, compatible version.

21reactions
seansfkelleycommented, Mar 10, 2020

In https://github.com/python-poetry/poetry/issues/496#issuecomment-455913689 there is also outlined an alternate workaround: poetry add pathlib2 ; poetry remove pathlib2, where pathlib2 is any library you don’t already depend on and that has no dependents… like pathlib2. (Strictly speaking, it can be any library with a dependency tree disjoint from your project, but why drag in more stuff than you need?)

I use this workaround all the time. Updating metadata in the lockfiles, resolving merge conflicts, etc. All of these operations get me into a state where I want something like poetry lock --preserve (which doesn’t exist, but has a nice ring to it): re-locking, but keeping as many versions as possible where they currently are.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - How to update Poetry's lock file without upgrading ...
There is a specific option for the lock command: poetry lock --no-update. This makes it possible to remove a dependency from pyproject.toml ...
Read more >
Yarn.lock: How to Update it - DEV Community ‍ ‍
lock file is important: it lists the packages that your application will end up using. Sure, your dependencies are listed in your package.json...
Read more >
Basic usage | Documentation | Poetry - Python dependency ...
Updating dependencies to their latest versions​​ As mentioned above, the poetry.lock file prevents you from automatically getting the latest versions of your  ......
Read more >
Yarn lock: how it works and what you risk without maintaining ...
Updating the lockfile is a bit easier to explain. An update can happen in 3 situations: When the dependency is added, removed, or...
Read more >
How Yarn Lock Files Work and Upgrading Dependencies
lock file as well as how to upgrade dependencies when a lock file is present. Many people see it as a nuisance to...
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