ruby/rubygems · error · InvalidOption

You need to pass a block to #source with :type option

Error message

You need to pass a block to #source with :type option

What it means

Error "You need to pass a block to #source with :type option" thrown in ruby/rubygems.

Source

Thrown at lib/bundler/dsl.rb:138

      cooldown = options["cooldown"]
      if cooldown && !(cooldown.is_a?(Integer) && cooldown >= 0)
        raise InvalidOption, "Expected `cooldown` to be a non-negative integer, got #{cooldown.inspect}"
      end

      if options.key?("type")
        options["type"] = options["type"].to_s
        unless (source_plugin = Plugin.source_plugin(options["type"]))
          raise InvalidOption, "No plugin sources available for #{options["type"]}"
        end
        # Implicitly add a dependency on source plugins who are named bundler-source-<type>,
        # and aren't already mentioned in the Gemfile.
        # See also Plugin::DSL#source
        if source_plugin.start_with?("bundler-source-") && !@dependencies.any? {|d| d.name == source_plugin }
          plugin(source_plugin)
        end

        unless block_given?
          raise InvalidOption, "You need to pass a block to #source with :type option"
        end

        source_opts = options.merge("uri" => source)
        with_source(@sources.add_plugin_source(options["type"], source_opts), &blk)
      elsif block_given?
        with_source(@sources.add_rubygems_source("remotes" => source, "cooldown" => cooldown), &blk)
      else
        @sources.add_global_rubygems_remote(source, cooldown: cooldown)
      end
    end

    def git_source(name, &block)
      unless block_given?
        raise InvalidOption, "You need to pass a block to #git_source"
      end

      if valid_keys.include?(name.to_s)
        raise InvalidOption, "You cannot use #{name} as a git source. It " \

View on GitHub (pinned to 86cbb817a3)

When it happens

Trigger: Thrown at lib/bundler/dsl.rb:138 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/d19d9c02d2fed5b7. Report an issue: GitHub.