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 --lock prints operations that don't run. #7588

Closed
4 tasks done
hwmq opened this issue Mar 1, 2023 · 2 comments · Fixed by #7915
Closed
4 tasks done

poetry update --lock prints operations that don't run. #7588

hwmq opened this issue Mar 1, 2023 · 2 comments · Fixed by #7915
Labels
area/cli Related to the command line kind/bug Something isn't working as expected

Comments

@hwmq
Copy link

hwmq commented Mar 1, 2023

  • Poetry version: 1.4.0

  • Python version: 3.10.6

  • OS version and name: Ubuntu 22.04

  • pyproject.toml: N/A

  • I am on the latest stable Poetry version, installed using a recommended method.

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

  • I have consulted the FAQ and blog for any relevant entries or release notes.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

poetry update --lock prints operations that don't run. The following gives the gist...

$ poetry update --lock mypackage
Updating dependencies
Resolving dependencies... (0.9s)

Writing lock file
  • Installing a_different_package (0.0.0): Pending...
  • Updating some_other_package (0.0.0 -> 1.0.0): Pending...
# ... and so on ...
$ # and back to my shell.

To be clear, some_other_package is not updated in the lock file.

Essentially, the printed operations correspond to what would happen in the poetry env if --lock were not specified. However since --lock is specified, it doesn't make sense to show this output, because these things do not happen.

We can see this here (tag 1.4.0)

self.installer.execute_operations(not self.option("lock"))

Poetry actually ends up reaching this line, which doesn't end up doing anything because self._execute_operations is False, but does print the output like above.

tasks.append(self._executor.submit(self._execute_operation, operation))

I wonder if when --lock is specified, should we also call self.installer.lock()? That way, the return in this block will execute. Currently it does not because self._lock is False

if self._update:
self._write_lock_file(lockfile_repo)
if self._lock:
# If we are only in lock mode, no need to go any further
return 0

add already does this.

if self.option("lock"):
self.installer.lock()

@hwmq hwmq added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Mar 1, 2023
@hwmq
Copy link
Author

hwmq commented Mar 11, 2023

Proposed fix. edit: this causes poetry update --lock to have the same bug as poetry add --lock (see #7309)

diff --git a/src/poetry/console/commands/update.py b/src/poetry/console/commands/update.py
index 955438a5..a6521a81 100644
--- a/src/poetry/console/commands/update.py
+++ b/src/poetry/console/commands/update.py
@@ -51,7 +51,11 @@ class UpdateCommand(InstallerCommand):
 
         self.installer.only_groups(self.activated_groups)
         self.installer.dry_run(self.option("dry-run"))
-        self.installer.execute_operations(not self.option("lock"))
+
+        if self.option("lock"):
+            self.installer.lock()
+        else:
+            self.installer.execute_operations()
 
         # Force update
         self.installer.update(True)

Results of poetry run pytest are the same with and without this patch.

@radoering radoering added area/cli Related to the command line and removed status/triage This issue needs to be triaged labels May 13, 2023
Copy link

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 Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/cli Related to the command line kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants