ruby/rubygems · error · InvalidOption

Unknown switches #{unknown.map(&:inspect).join(', ')}

Error message

Unknown switches #{unknown.map(&:inspect).join(', ')}

What it means

Error "Unknown switches #{unknown.map(&:inspect).join(', ')}" thrown in ruby/rubygems.

Source

Thrown at lib/bundler/cli.rb:87

        # lock --lockfile works differently than install --lockfile
        unless current_cmd == "lock"
          custom_lockfile = options[:lockfile] || ENV["BUNDLE_LOCKFILE"] || Bundler.settings[:lockfile]
          if custom_lockfile && !custom_lockfile.empty?
            Bundler::SharedHelpers.set_env "BUNDLE_LOCKFILE", File.expand_path(custom_lockfile)
            reset_settings = true
          end
        end
      end

      Bundler.reset_settings_and_root! if reset_settings

      Bundler.auto_switch

      Bundler.settings.set_command_option_if_given :retry, options[:retry]

      Bundler.auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
    rescue UnknownArgumentError => e
      raise InvalidOption, e.message
    ensure
      self.options ||= {}
      unprinted_warnings = Bundler.ui.unprinted_warnings
      Bundler.ui = UI::Shell.new(options)
      Bundler.ui.level = "debug" if options[:verbose] || Bundler.settings[:verbose]
      unprinted_warnings.each {|w| Bundler.ui.warn(w) }
    end

    check_unknown_options!(except: [:config, :exec])
    stop_on_unknown_option! :exec

    desc "cli_help", "Prints a summary of bundler commands", hide: true
    def cli_help
      version
      Bundler.ui.info "\n"

      primary_commands = ["install", "update", "cache", "exec", "config", "help"]

View on GitHub (pinned to 86cbb817a3)

When it happens

Trigger: Thrown at lib/bundler/cli.rb:87 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/3fb5c843bb7af21b. Report an issue: GitHub.