ruby/rubygems · error · Bundler::InvalidOption

Please specify gems to add.

Error message

Please specify gems to add.

What it means

Error "Please specify gems to add." thrown in ruby/rubygems.

Source

Thrown at lib/bundler/cli/add.rb:55

        pessimistic: options[:pessimistic],
        strict: options[:strict])
    end

    def validate_options!
      raise InvalidOption, "You cannot specify `--git` and `--github` at the same time." if options["git"] && options["github"]

      unless options["git"] || options["github"]
        raise InvalidOption, "You cannot specify `--branch` unless `--git` or `--github` is specified." if options["branch"]

        raise InvalidOption, "You cannot specify `--ref` unless `--git` or `--github` is specified." if options["ref"]
      end

      raise InvalidOption, "You cannot specify `--branch` and `--ref` at the same time." if options["branch"] && options["ref"]

      raise InvalidOption, "You cannot specify `--strict` and `--pessimistic` at the same time." if options[:strict] && options[:pessimistic]

      # raise error when no gems are specified
      raise InvalidOption, "Please specify gems to add." if gems.empty?

      version.to_a.each do |v|
        raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN.match?(v.to_s)
      end
    end
  end
end

View on GitHub (pinned to 86cbb817a3)

When it happens

Trigger: Thrown at lib/bundler/cli/add.rb:55 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/6be7c0d02d016cb9. Report an issue: GitHub.