Skip to content

poetry update --dry-run modifies poetry.lock #3766

Closed

Description

@martinmo
  • 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

When poetry update is called with the --dry-run argument, the expected outcome is that the file poetry.lock remains unmodified.

However, a regression introduced in poetry version 1.1.1 (it seems, via PR #3034) modifies this file regardless of the --dry-run flag.

To reproduce using the above gist:

$ git clone https://gist.github.com/bf32a5e6278f9edc74eb3f7787e5b372.git poetry-bug && cd poetry-bug
$ poetry -V
Poetry version 1.1.5
$ poetry config --list
cache-dir = "/Users/martin/Library/Caches/pypoetry"
experimental.new-installer = false
installer.parallel = false
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/martin/Library/Caches/pypoetry/virtualenvs
$ poetry update --dry-run
Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Package operations: 1 install, 0 updates, 0 removals

  - Installing defusedxml (0.7.1)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   poetry.lock

no changes added to commit (use "git add" and/or "git commit -a")

With poetry 1.1.0, it works as expected:

$ git checkout poetry.lock
$ pipx install --suffix @1.1.0 'poetry==1.1.0'
$ poetry@1.1.0 -V
Poetry version 1.1.0
$ poetry@1.1.0 update --dry-run
Updating dependencies
Resolving dependencies... (0.1s)

Package operations: 1 install, 0 updates, 0 removals

  - Installing defusedxml (0.7.1)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

As of now, poetry's master is also affected. It happens regardless of the experimental.new-installer and installer.parallel settings.

I have already written a unit test to reproduce this and an according fix that I'll submit as a PR in a minute.

Activity

  1. added
    kind/bugSomething isn't working as expected
    status/triageThis issue needs to be triaged
    on Mar 10, 2021
  2. justinmayer commented on Mar 27, 2021

    @justinmayer
    Contributor

    See also: #3739 #3666

  3. languitar commented on Jun 29, 2021

    @languitar

    This is highly annoying in case of merge conflicts in the lock file. Using poetry lock --no-update would be one version to resolve the conflicts, but implicitly changing versions with this command might trigger a cascade of further errors.

  4. brettborowski commented on Jul 12, 2021

    @brettborowski

    Does this also affect poetry add --dry-run as well?

  5. martinmo commented on Jul 13, 2021

    @martinmo
    Author

    Yes, I would think so, because in addition to the update command it was also reported that the remove and lock commands are affected. This makes sense, as the function _write_lock_file(…) in poetry/installation/installer.py#L335 sets force to True by default and modifies the lockfile if force is True. This is what I've changed in my PR (see above).

  6. Stannislav commented on Aug 26, 2021

    @Stannislav

    Bug still present in the latest Poetry version 1.1.8.

  7. zEdS15B3GCwq commented on Apr 5, 2022

    @zEdS15B3GCwq

    Still present in 1.2.0b1. Please proceed with PR. Much appreciated.

  8. github-actions commented on Mar 2, 2024

    @github-actions

    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.

  9. locked as resolved and limited conversation to collaborators on Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions