{"record":{"id":"7df2c63b37944e13","repo":"ruby/rubygems","slug":"not-connected-to-a-tty-and-no-default-specified","errorCode":null,"errorMessage":"Not connected to a tty and no default specified","messagePattern":"Not connected to a tty and no default specified","errorType":"exception","errorClass":"Gem::OperationNotSupportedError","httpStatus":null,"severity":"error","filePath":"lib/rubygems/user_interaction.rb","lineNumber":249,"sourceCode":"\n    result = @ins.gets\n\n    return nil, nil unless result\n\n    result = result.strip.to_i - 1\n    return nil, nil unless (0...list.size) === result\n    [list[result], result]\n  end\n\n  ##\n  # Ask a question.  Returns a true for yes, false for no.  If not connected\n  # to a tty, raises an exception if default is nil, otherwise returns\n  # default.\n\n  def ask_yes_no(question, default = nil)\n    unless tty?\n      if default.nil?\n        raise Gem::OperationNotSupportedError,\n              \"Not connected to a tty and no default specified\"\n      else\n        return default\n      end\n    end\n\n    default_answer = case default\n                     when nil\n                       \"yn\"\n                     when true\n                       \"Yn\"\n                     else\n                       \"yN\"\n    end\n\n    result = nil\n\n    while result.nil? do","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/rubygems/user_interaction.rb#L231-L267","documentation":"Error \"Not connected to a tty and no default specified\" thrown in ruby/rubygems.","triggerScenarios":"Thrown at lib/rubygems/user_interaction.rb:249 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the command interactively (on a TTY) to answer the prompt","Or pass the option/default that avoids the prompt (e.g. --no-interactive flags where available)"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"86cbb817a38ce8477b181c17467a703ded3f2be8","analyzedAt":"2026-08-23T06:27:48.159Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}