{"record":{"id":"dc611c7f51ce114f","repo":"pypa/pip","slug":"no-input-was-expected-pip-no-input-set-questio","errorCode":null,"errorMessage":"No input was expected ($PIP_NO_INPUT set); question: {message}","messagePattern":"No input was expected \\(\\$PIP_NO_INPUT set\\); question: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/utils/misc.py","lineNumber":253,"sourceCode":"    n = 1\n    extension = ext\n    while os.path.exists(dir + extension):\n        n += 1\n        extension = ext + str(n)\n    return dir + extension\n\n\ndef ask_path_exists(message: str, options: Iterable[str]) -> str:\n    for action in os.environ.get(\"PIP_EXISTS_ACTION\", \"\").split():\n        if action in options:\n            return action\n    return ask(message, options)\n\n\ndef _check_no_input(message: str) -> None:\n    \"\"\"Raise an error if no input is allowed.\"\"\"\n    if os.environ.get(\"PIP_NO_INPUT\"):\n        raise Exception(\n            f\"No input was expected ($PIP_NO_INPUT set); question: {message}\"\n        )\n\n\ndef ask(message: str, options: Iterable[str]) -> str:\n    \"\"\"Ask the message interactively, with the given possible responses\"\"\"\n    while 1:\n        _check_no_input(message)\n        response = input(message)\n        response = response.strip().lower()\n        if response not in options:\n            print(\n                \"Your response ({!r}) was not one of the expected responses: \"\n                \"{}\".format(response, \", \".join(options))\n            )\n        else:\n            return response\n","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/utils/misc.py#L235-L271","documentation":"Raised as a generic Exception by _check_no_input (misc.py:253) when the PIP_NO_INPUT environment variable is set and pip needs to ask the user an interactive question (confirmation prompt, choice selection, or password). Setting PIP_NO_INPUT (equivalent to --no-input) tells pip to never prompt for input; if it reaches a code path that requires input, it fails immediately rather than hanging on a blocked stdin. This is essential for non-interactive CI/automation.","triggerScenarios":"PIP_NO_INPUT=1 is set (or --no-input passed) and pip encounters a situation requiring a prompt: ask(), ask_path_exists(), ask_input(), or ask_password() all call _check_no_input first (lines 261, 275, 281). Examples: a file-exists confirmation, a keyring/Git credential prompt, or a dependency conflict that needs a user decision.","commonSituations":"CI pipelines with PIP_NO_INPUT=1 where pip needs confirmation for an overwrite (PIP_EXISTS_ACTION not set). Docker builds with --no-input that encounter a package needing credential input for a private index. Automation scripts that set PIP_NO_INPUT globally and hit an unexpected prompt.","solutions":["Set PIP_EXISTS_ACTION=a (or the relevant action letters) to auto-answer file-exists prompts without interaction.","Provide credentials via environment variables (PIP_INDEX_USER, PIP_INDEX_PASSWORD), a keyring, or a netrc file instead of interactive prompts.","Remove PIP_NO_INPUT if you actually want interactive prompts.","Pre-resolve the condition causing the prompt (e.g. clean the target directory, pin versions to avoid conflicts)."],"exampleFix":"// before\nexport PIP_NO_INPUT=1\npip install pkg  # hits overwrite confirmation\n\n// after\nexport PIP_NO_INPUT=1\nexport PIP_EXISTS_ACTION=a\npip install pkg","handlingStrategy":"validation","validationCode":"import os\n\ndef ensure_no_prompt_conflicts():\n    \"\"\"Set PIP_EXISTS_ACTION and credentials before PIP_NO_INPUT to avoid prompts.\"\"\"\n    if os.environ.get('PIP_NO_INPUT'):\n        os.environ.setdefault('PIP_EXISTS_ACTION', 'a')  # auto-overwrite\n        if not (os.environ.get('PIP_INDEX_USER') or os.path.get('PIP_INDEX_URL')):\n            print('Warning: PIP_NO_INPUT set but no non-interactive credentials configured.')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair PIP_NO_INPUT=1 with PIP_EXISTS_ACTION to handle overwrite prompts.","Provide index credentials via env vars or netrc rather than interactive prompts.","Test pip commands in CI before deploying to ensure no hidden prompt triggers."],"tags":["no-input","automation","ci","environment","interactive"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}