{"record":{"id":"d19d9c02d2fed5b7","repo":"ruby/rubygems","slug":"you-need-to-pass-a-block-to-source-with-type-opt","errorCode":null,"errorMessage":"You need to pass a block to #source with :type option","messagePattern":"You need to pass a block to #source with :type option","errorType":"exception","errorClass":"InvalidOption","httpStatus":null,"severity":"error","filePath":"lib/bundler/dsl.rb","lineNumber":138,"sourceCode":"      cooldown = options[\"cooldown\"]\n      if cooldown && !(cooldown.is_a?(Integer) && cooldown >= 0)\n        raise InvalidOption, \"Expected `cooldown` to be a non-negative integer, got #{cooldown.inspect}\"\n      end\n\n      if options.key?(\"type\")\n        options[\"type\"] = options[\"type\"].to_s\n        unless (source_plugin = Plugin.source_plugin(options[\"type\"]))\n          raise InvalidOption, \"No plugin sources available for #{options[\"type\"]}\"\n        end\n        # Implicitly add a dependency on source plugins who are named bundler-source-<type>,\n        # and aren't already mentioned in the Gemfile.\n        # See also Plugin::DSL#source\n        if source_plugin.start_with?(\"bundler-source-\") && !@dependencies.any? {|d| d.name == source_plugin }\n          plugin(source_plugin)\n        end\n\n        unless block_given?\n          raise InvalidOption, \"You need to pass a block to #source with :type option\"\n        end\n\n        source_opts = options.merge(\"uri\" => source)\n        with_source(@sources.add_plugin_source(options[\"type\"], source_opts), &blk)\n      elsif block_given?\n        with_source(@sources.add_rubygems_source(\"remotes\" => source, \"cooldown\" => cooldown), &blk)\n      else\n        @sources.add_global_rubygems_remote(source, cooldown: cooldown)\n      end\n    end\n\n    def git_source(name, &block)\n      unless block_given?\n        raise InvalidOption, \"You need to pass a block to #git_source\"\n      end\n\n      if valid_keys.include?(name.to_s)\n        raise InvalidOption, \"You cannot use #{name} as a git source. It \" \\","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/bundler/dsl.rb#L120-L156","documentation":"Error \"You need to pass a block to #source with :type option\" thrown in ruby/rubygems.","triggerScenarios":"Thrown at lib/bundler/dsl.rb:138 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"86cbb817a38ce8477b181c17467a703ded3f2be8","analyzedAt":"2026-08-23T06:27:48.159Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}