ruby/rubygems · error · InvalidOption
You cannot specify `--git` and `--github` at the same time.
Error message
You cannot specify `--git` and `--github` at the same time.
What it means
Error "You cannot specify `--git` and `--github` at the same time." thrown in ruby/rubygems.
Source
Thrown at lib/bundler/cli/add.rb:42
private
def perform_bundle_install
Installer.install(Bundler.root, Bundler.definition)
Bundler.load.cache if Bundler.app_cache.exist?
end
def inject_dependencies
dependencies = gems.map {|g| Bundler::Dependency.new(g, version, options) }
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
endView on GitHub (pinned to 86cbb817a3)
When it happens
Trigger: Thrown at lib/bundler/cli/add.rb:42 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/b037e13ac1674f6c.
Report an issue: GitHub.