Repository navigation
fix(plugins): name the plugin that fails to load or activate - #11182
Open
Thanatos9404 wants to merge 2 commits into
Open
Thanatos9404 wants to merge 2 commits into
Thanatos9404 wants to merge 2 commits into
Conversation
When a plugin raised while being loaded or activated, every command failed with only that error, so a conflicting command name or a broken import gave no hint which plugin was at fault or that --no-plugins gets Poetry working again. Re-raise with the entry point name and distribution, keep the original exception as the cause, and point to --no-plugins.
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Linked issues
#6456 Poetry can get locked into an unusable state with plugins: 'The command "..." already exists' · 1 of 1 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Recover Poetry when conflicting plugins make commands fail, without manually removing plugins from its environment. | ✅ Met | The activation error now identifies the plugin and points to --no-plugins; the application test verifies that the command works with plugins disabled. |
Sourcery assessment
Approved.
PackageMetadata.get is only in the typing stubs from Python 3.12, so mypy failed on 3.11. Distribution.name and Distribution.version give the same values and are what the rest of Poetry already uses.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Check List
Resolves: #6456
When a plugin fails to load or activate, every Poetry command fails with only the plugin's own error. Take the case from the issue: the deprecated
poetry-dynamic-versioning-pluginis installed next topoetry-dynamic-versioning, and both register the same command. Then evenpoetry --helpprints just:--no-pluginshas been there since 1.2.0 and does get Poetry working again, but nothing points to it or to the plugin at fault. That is what makes it look like Poetry is stuck.PluginManagernow keeps the entry point of each loaded plugin. Whenep.load()or a plugin'sactivateraises, it re-raises with the entry point name and the distribution, and keeps the original exception as the cause. The same setup now prints:A plugin broken by an upgrade gets the same treatment, for example
Failed to load the "my-plugin" plugin: No module named '...'.Notes on the behaviour:
-v, the original traceback is still shown, because the new error is raisedfromthe original.poetry.pluginplugins activated inFactory.create_poetry.assertinApplicationPlugin.activate, is reported by its type name.Tests:
tests/plugins/test_plugin_manager.pychecks the message and the cause for an activation error (including an exception without a message) and for an import error while loading.tests/console/test_application.py::test_application_with_failing_pluginregisters a plugin with an existingaboutcommand, checks the error output, and checks thatabout --no-pluginsstill works.The new tests fail on
mainand pass with this change. The full test suite passes locally on Windows excepttest_install_dir_is_symlinkandtest_python_get_preferred_default, which fail the same way onmain.ruff check,ruff format --check(0.16.6) andmypyare clean.docs/plugins.mdgets two sentences on recovering with--no-plugins.#11139 also changes
PluginManager.activate, so whichever of the two is merged second will need a small rebase.