ruby/rubygems · error · Bundler::InvalidOption

You cannot specify `--strict` and `--pessimistic` at the sam

Error message

You cannot specify `--strict` and `--pessimistic` at the same time.

What it means

Error "You cannot specify `--strict` and `--pessimistic` at the same time." thrown in ruby/rubygems.

Source

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

      Injector.inject(dependencies,
        conservative_versioning: options[:version].nil?, # Perform conservative versioning only when version is not specified
        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:52 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/ac6ed8c45165c88f. Report an issue: GitHub.