{"record":{"id":"2ead8628a8997154","repo":"pypa/pip","slug":"no-binary-only-binary-option-requires-1-argu","errorCode":null,"errorMessage":"--no-binary / --only-binary option requires 1 argument.","messagePattern":"--no-binary / --only-binary option requires 1 argument\\.","errorType":"validation","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/models/format_control.py","lineNumber":41,"sourceCode":"        self.no_binary = no_binary\n        self.only_binary = only_binary\n\n    def __eq__(self, other: object) -> bool:\n        if not isinstance(other, self.__class__):\n            return NotImplemented\n\n        if self.__slots__ != other.__slots__:\n            return False\n\n        return all(getattr(self, k) == getattr(other, k) for k in self.__slots__)\n\n    def __repr__(self) -> str:\n        return f\"{self.__class__.__name__}({self.no_binary}, {self.only_binary})\"\n\n    @staticmethod\n    def handle_mutual_excludes(value: str, target: set[str], other: set[str]) -> None:\n        if value.startswith(\"-\"):\n            raise CommandError(\n                \"--no-binary / --only-binary option requires 1 argument.\"\n            )\n        new = value.split(\",\")\n        while \":all:\" in new:\n            other.clear()\n            target.clear()\n            target.add(\":all:\")\n            del new[: new.index(\":all:\") + 1]\n            # Without a none, we want to discard everything as :all: covers it\n            if \":none:\" not in new:\n                return\n        for name in new:\n            if name == \":none:\":\n                target.clear()\n                continue\n            name = canonicalize_name(name)\n            other.discard(name)\n            target.add(name)","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/models/format_control.py#L23-L59","documentation":"Raised as CommandError from FormatControl.handle_mutual_excludes in format_control.py:40-43. The --no-binary / --only-binary options each expect exactly one argument value; if the parsed value starts with '-' (i.e. no package name was supplied and the next token looks like a flag), pip rejects it rather than silently consuming an unrelated flag as the package list.","triggerScenarios":"Passing `--no-binary` or `--only-binary` without a following value, or with a value beginning with '-', so handle_mutual_excludes sees value.startswith('-') and raises CommandError.","commonSituations":"Typing `pip install --no-binary` with no argument; a shell quoting mistake that drops the package name; a script concatenating flags where the value slot is empty.","solutions":["Supply a package name or ':all:'/:none:' after --no-binary/--only-binary (e.g. --no-binary=:all: or --no-binary pandas).","Check shell quoting/expansion so the intended value is not dropped.","Review the command line for a missing argument before running."],"exampleFix":"// before\npip install --no-binary mypkg\n// after\npip install --no-binary=:all: mypkg","handlingStrategy":"validation","validationCode":"// Before forwarding to pip, ensure --no-binary/--only-binary have a non-flag value:\nfor i, a in enumerate(argv):\n    if a in ('--no-binary', '--only-binary'):\n        val = argv[i+1] if i+1 < len(argv) else ''\n        if not val or val.startswith('-'):\n            raise SystemExit(f'{a} requires one non-flag argument')","typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import CommandError\ntry:\n    FormatControl.handle_mutual_excludes(value, target, other)\nexcept CommandError as e:\n    if 'requires 1 argument' in str(e):\n        # prompt user for the missing value\n        ...","preventionTips":["Always pass an explicit value (:all:, :none:, or a name) to --no-binary/--only-binary.","Validate argv in wrapper scripts for flag/value pairing.","Use shell arrays/quoting carefully to avoid dropping arguments."],"tags":["cli","format-control","argument-error","validation"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}