ruby/rubygems · error · InvalidOption

You need to pass a block to #git_source

Error message

You need to pass a block to #git_source

What it means

Error "You need to pass a block to #git_source" thrown in ruby/rubygems.

Source

Thrown at lib/bundler/dsl.rb:152

          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 " \
          "is a reserved key. Reserved keys are: #{valid_keys.join(", ")}"
      end

      @git_sources[name.to_s] = block
    end

    def path(path, options = {}, &blk)
      source_options = normalize_hash(options).merge(
        "path" => Pathname.new(path),
        "root_path" => gemfile_root
      )

      source_options["global"] = true unless block_given?

View on GitHub (pinned to 86cbb817a3)

When it happens

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