{"id":"2779d1008d3e3d88","repo":"pytest-dev/pytest","slug":"plugin-name-cannot-be-disabled","errorCode":null,"errorMessage":"plugin {name} cannot be disabled","messagePattern":"plugin (.+?) cannot be disabled","errorType":"validation","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":849,"sourceCode":"                        parg = args[i]\n                    except IndexError:\n                        return\n                    i += 1\n                elif opt.startswith(\"-p\"):\n                    parg = opt[2:]\n                else:\n                    continue\n                parg = parg.strip()\n                if exclude_only and not parg.startswith(\"no:\"):\n                    continue\n                self.consider_pluginarg(parg)\n\n    def consider_pluginarg(self, arg: str) -> None:\n        \"\"\":meta private:\"\"\"\n        if arg.startswith(\"no:\"):\n            name = arg[3:]\n            if name in essential_plugins:\n                raise UsageError(f\"plugin {name} cannot be disabled\")\n\n            if name.endswith(\"conftest.py\"):\n                raise UsageError(\n                    f\"Blocking conftest files using -p is not supported: -p no:{name}\\n\"\n                    \"conftest.py files are not plugins and cannot be disabled via -p.\\n\"\n                )\n\n            # PR #4304: remove stepwise if cacheprovider is blocked.\n            if name == \"cacheprovider\":\n                self.set_blocked(\"stepwise\")\n                self.set_blocked(\"pytest_stepwise\")\n\n            self.set_blocked(name)\n            if not name.startswith(\"pytest_\"):\n                self.set_blocked(\"pytest_\" + name)\n        else:\n            name = arg\n            # Unblock the plugin.","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/__init__.py#L831-L867","documentation":"Certain pytest plugins are essential for core functionality (mark, main, runner, fixtures, helpconfig) and cannot be disabled with -p no:NAME. Attempting to block one raises UsageError in consider_pluginarg(). Disabling them would break test collection and execution entirely.","triggerScenarios":"Running pytest with -p no:mark, -p no:fixtures, -p no:runner, -p no:main, or -p no:helpconfig. The name is found in the essential_plugins tuple, so UsageError is raised.","commonSituations":"Trying to speed up pytest by disabling 'unused' plugins, or cargo-culting -p no:X flags from a config file without understanding which are essential.","solutions":["Remove the -p no:<essential_plugin> flag for the blocked plugin.","If you need to change fixture or marker behavior, use the appropriate pytest hooks/options instead of disabling the plugin.","Review the essential_plugins tuple in src/_pytest/config/__init__.py to know which names are off-limits."],"exampleFix":"# before\npytest -p no:fixtures\n\n# after\npytest  # do not disable core fixtures plugin","handlingStrategy":"validation","validationCode":"# Essential plugins that cannot be disabled via -p no:NAME\nESSENTIAL_PLUGINS = {'mark', 'main', 'runner', 'fixtures', 'helpconfig'}\n\ndef safe_disable_plugin(name: str) -> str:\n    if name in ESSENTIAL_PLUGINS:\n        raise ValueError(f\"Cannot disable essential plugin '{name}'\")\n    return f'-p no:{name}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never include -p no:<name> for mark, main, runner, fixtures, or helpconfig.","Audit pytest invocations in CI scripts for -p no: flags against the essential_plugins list."],"tags":["config","cli","plugins","usage-error"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}