ruby/rubygems · error · InvalidOption

You cannot use #{name} as a git source. It is a reserved key

Error message

You cannot use #{name} as a git source. It is a reserved key. Reserved keys are: #{valid_keys.join(", ")}

What it means

Error "You cannot use #{name} as a git source. It is a reserved key. Reserved keys are: #{valid_keys.join(", ")}" thrown in ruby/rubygems.

Source

Thrown at lib/bundler/dsl.rb:156

          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?

      source = @sources.add_path_source(source_options)
      with_source(source, &blk)
    end

View on GitHub (pinned to 86cbb817a3)

When it happens

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