Skip to content

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

@martinmo

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'
$ [email protected] -V
Poetry version 1.1.0
$ [email protected] 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.

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