ruby/rubygems · error · Bundler::InvalidOption

The `--name-only` and `--paths` options cannot be used toget

Error message

The `--name-only` and `--paths` options cannot be used together

What it means

Error "The `--name-only` and `--paths` options cannot be used together" thrown in ruby/rubygems.

Source

Thrown at lib/bundler/cli/list.rb:17

# frozen_string_literal: true

require "json"

module Bundler
  class CLI::List
    def initialize(options)
      @options = options
      @without_group = options["without-group"].map(&:to_sym)
      @only_group = options["only-group"].map(&:to_sym)
      @format = options["format"]
    end

    def run
      raise InvalidOption, "The `--only-group` and `--without-group` options cannot be used together" if @only_group.any? && @without_group.any?

      raise InvalidOption, "The `--name-only` and `--paths` options cannot be used together" if @options["name-only"] && @options[:paths]

      specs = if @only_group.any? || @without_group.any?
        filtered_specs_by_groups
      else
        begin
          Bundler.load.specs
        rescue GemNotFound => e
          Bundler.ui.error e.message
          Bundler.ui.warn "Install missing gems with `bundle install`."
          exit 1
        end
      end.reject {|s| s.name == "bundler" }.sort_by(&:name)

      case @format
      when "json"
        print_json(specs: specs)
      when nil
        print_human(specs: specs)

View on GitHub (pinned to 86cbb817a3)

When it happens

Trigger: Thrown at lib/bundler/cli/list.rb:17 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/74d39991146810bd. Report an issue: GitHub.