{"id":"0366dc261f712c91","repo":"python-poetry/poetry","slug":"you-can-not-combine-a-setting-value-with-unset","errorCode":null,"errorMessage":"You can not combine a setting value with --unset","messagePattern":"You can not combine a setting value with --unset","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"src/poetry/console/commands/config.py","lineNumber":161,"sourceCode":"\n        if self.option(\"local\"):\n            config.set_config_source(FileConfigSource(local_config_file))\n\n        if not config_file.exists():\n            config_file.path.parent.mkdir(parents=True, exist_ok=True)\n            config_file.path.touch(mode=0o0600)\n\n        if self.option(\"list\"):\n            self._list_configuration(config.all(), config.raw())\n\n            return 0\n\n        setting_key = self.argument(\"key\")\n        if not setting_key:\n            return 0\n\n        if self.argument(\"value\") and self.option(\"unset\"):\n            raise RuntimeError(\"You can not combine a setting value with --unset\")\n\n        repo_regex = r\"^repos?(?:itories)?(?:\\.(.+?)(?:\\.(url))?)?$\"\n\n        # show the value if no value is provided\n        if not self.argument(\"value\") and not self.option(\"unset\"):\n            if setting_key.split(\".\")[0] in self.LIST_PROHIBITED_SETTINGS:\n                raise ValueError(f\"Expected a value for {setting_key} setting.\")\n\n            value: str | dict[str, Any] | list[str]\n\n            if m := re.match(\n                r\"installer\\.build-config-settings(\\.([^.]+))?\", self.argument(\"key\")\n            ):\n                if not m.group(1):\n                    if value := config.get(\"installer.build-config-settings\"):\n                        self._list_configuration(value, value)\n                    else:\n                        self.line(\"No packages configured with build config settings.\")","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/console/commands/config.py#L143-L179","documentation":"Raises RuntimeError in ConfigCommand.handle() when the user provides both a setting value AND the --unset flag. These are mutually exclusive: --unset removes a setting, while providing a value sets it. The check at line 160-161 is `if self.argument('value') and self.option('unset')`.","triggerScenarios":"Running `poetry config virtualenvs.create true --unset` — passing a value argument alongside --unset.","commonSituations":"User accidentally leaves a stale value in the command or misunderstands that --unset takes no value.","solutions":["To unset a setting, omit the value: `poetry config virtualenvs.create --unset`.","To set a value, omit --unset: `poetry config virtualenvs.create true`."],"exampleFix":"# before (error)\npoetry config virtualenvs.create true --unset\n# after (to unset)\npoetry config virtualenvs.create --unset\n# after (to set)\npoetry config virtualenvs.create true","handlingStrategy":"validation","validationCode":"def validate_config_args(value, unset: bool) -> None:\n    if value and unset:\n        raise ValueError(\"Cannot combine a setting value with --unset; choose one or the other\")","typeGuard":"def are_config_args_valid(value, unset: bool) -> bool:\n    return not (value and unset)","tryCatchPattern":null,"preventionTips":["Never pass a value and --unset together; they are mutually exclusive.","Use --unset alone to remove, or value alone to set.","Double-check command history before appending --unset."],"tags":["config-command","runtimeerror","mutually-exclusive-options","cli-validation"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}