ruby/rubygems · error · Gem::OptionParser::InvalidArgument

invalid argument: #{value}

Error message

invalid argument: #{value}

What it means

Error "invalid argument: #{value}" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/local_remote_options.rb:24

# See LICENSE.txt for permissions.
#++

require_relative "vendor/uri/lib/uri"
require_relative "../rubygems"

##
# Mixin methods for local and remote Gem::Command options.

module Gem::LocalRemoteOptions
  ##
  # Allows Gem::OptionParser to handle HTTP URIs.

  def accept_uri_http
    Gem::OptionParser.accept Gem::URI::HTTP do |value|
      begin
        uri = Gem::URI.parse value
      rescue Gem::URI::InvalidURIError
        raise Gem::OptionParser::InvalidArgument, value
      end

      valid_uri_schemes = ["http", "https", "file", "s3"]
      unless valid_uri_schemes.include?(uri.scheme)
        msg = "Invalid uri scheme for #{value}\nPreface URLs with one of #{valid_uri_schemes.map {|s| "#{s}://" }}"
        raise ArgumentError, msg
      end

      value
    end
  end

  ##
  # Add local/remote options to the command line parser.

  def add_local_remote_options
    add_option(:"Local/Remote", "-l", "--local",
               "Restrict operations to the LOCAL domain") do |_value, options|

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. Check the option value you passed; it must match the expected format (see `gem help <command>`)

When it happens

Trigger: Thrown at lib/rubygems/local_remote_options.rb:24 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruby/rubygems@86cbb817a3 (2026-08-23). Data as JSON: /api/errors/5255b5f53cc798fd. Report an issue: GitHub.