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

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

Closed
3 tasks done
martinmo opened this issue Mar 10, 2021 · 7 comments · Fixed by #5718
Closed
3 tasks done

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

martinmo opened this issue Mar 10, 2021 · 7 comments · Fixed by #5718
Labels
kind/bug Something isn't working as expected

Comments

@martinmo
Copy link

  • 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.

@martinmo martinmo added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Mar 10, 2021
@justinmayer
Copy link
Contributor

See also: #3739 #3666

@languitar
Copy link

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.

@brettborowski
Copy link

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

@martinmo
Copy link
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).

@Stannislav
Copy link

Bug still present in the latest Poetry version 1.1.8.

@zEdS15B3GCwq
Copy link

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

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/bug Something isn't working as expected
Projects
None yet
7 participants