{"record":{"id":"2bcedaca5a49aaf1","repo":"ruby/ruby","slug":"you-can-no-longer-specify-a-git-source-by-itself","errorCode":null,"errorMessage":"You can no longer specify a git source by itself. Instead, \neither use the :git option on a gem, or specify the gems that \nbundler should find in the git source by passing a block to \nthe git method, like: \n\n  git 'git://github.com/rails/rails.git' do\n    gem 'rails'\n  end","messagePattern":"You can no longer specify a git source by itself\\. Instead, \neither use the :git option on a gem, or specify the gems that \nbundler should find in the git source by passing a block to \nthe git method, like: \n\n  git 'git://github\\.com/rails/rails\\.git' do\n    gem 'rails'\n  end","errorType":"exception","errorClass":"DeprecatedError","httpStatus":null,"severity":"error","filePath":"lib/bundler/dsl.rb","lineNumber":184,"sourceCode":"        \"root_path\" => gemfile_root\n      )\n\n      source_options[\"global\"] = true unless block_given?\n\n      source = @sources.add_path_source(source_options)\n      with_source(source, &blk)\n    end\n\n    def git(uri, options = {}, &blk)\n      unless block_given?\n        msg = \"You can no longer specify a git source by itself. Instead, \\n\" \\\n              \"either use the :git option on a gem, or specify the gems that \\n\" \\\n              \"bundler should find in the git source by passing a block to \\n\" \\\n              \"the git method, like: \\n\\n\" \\\n              \"  git 'git://github.com/rails/rails.git' do\\n\" \\\n              \"    gem 'rails'\\n\" \\\n              \"  end\"\n        raise DeprecatedError, msg\n      end\n\n      with_source(@sources.add_git_source(normalize_hash(options).merge(\"uri\" => uri)), &blk)\n    end\n\n    def github(repo, options = {})\n      raise InvalidArgumentError, \"GitHub sources require a block\" unless block_given?\n      github_uri  = @git_sources[\"github\"].call(repo)\n      git_options = normalize_hash(options).merge(\"uri\" => github_uri)\n      git_source  = @sources.add_git_source(git_options)\n      with_source(git_source) { yield }\n    end\n\n    SUPPORTED_OVERRIDE_FIELDS = [:version, :required_ruby_version, :required_rubygems_version].freeze\n    SUPPORTED_OVERRIDE_SYMBOL_OPERATIONS = [:ignore_upper].freeze\n\n    def override(target, **operations)\n      validate_override_target!(target)","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/ruby/ruby/blob/0e5b888e1c355f3f728f2659f085820937dada48/lib/bundler/dsl.rb#L166-L202","documentation":"In Bundler 1.x, `git \"git://...\"` alone declared a git source and later gems could attach to it implicitly. Bundler 2 removed implicit attachment, so calling `git` without a block raises DeprecatedError with migration instructions: either pass :git per gem or enumerate the gems in a block. This is a hard migration error, not a warning.","triggerScenarios":"A Gemfile written for Bundler 1.x containing a bare `git \"git://github.com/rails/rails.git\"` line, evaluated under Bundler 2+. Often surfaces after upgrading Bundler or when an old project is opened with a newer toolchain.","commonSituations":"Upgrading from Bundler 1.17 to 2.x; legacy Gemfiles in long-lived internal projects; tutorial/documentation examples predating Bundler 2.","solutions":["Move the repo onto the gems that use it with a block: `git \"https://github.com/rails/rails.git\" do; gem \"rails\"; end`.","Or attach per gem: `gem \"rails\", git: \"https://github.com/rails/rails.git\"`.","For shared shorthands, define git_source(:github){...} and use `gem \"rails\", github: \"rails/rails\"`.","If you cannot edit the Gemfile yet, run with the legacy Bundler 1.x version (`gem install bundler -v '~> 1.17'` then `bundle _1.17.3_ install`)."],"exampleFix":"# before (Bundler 1.x style)\ngit \"git://github.com/rails/rails.git\"\ngem \"rails\"\n\n# after (Bundler 2+)\ngit \"https://github.com/rails/rails.git\" do\n  gem \"rails\"\nend","handlingStrategy":"validation","validationCode":"# Lint legacy Gemfiles before running Bundler 2\ncontent = File.read(\"Gemfile\")\nif content =~ /^\\s*git\\s+[\"'][^\"']+[\"']\\s*$/ && !content.match?(/^\\s*git\\s+[\"'][^\"']+[\"']\\s+do/)\n  abort \"Bare `git \\\"url\\\"` lines must be migrated to block form or `gem ..., git:`\"\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["During Bundler 1→2 upgrades, run `bundle install` and fix each DeprecatedError by wrapping gems in the git block.","Use `gem \"x\", git: \"...\"` as the modern default; it is unambiguous.","Note the git:// protocol is dead on GitHub — migrate to https:// at the same time."],"tags":["bundler","gemfile","git-source","deprecation","bundler-2-migration"],"backgroundTag":"deprecated-api-removed","analyzedSha":"0e5b888e1c355f3f728f2659f085820937dada48","analyzedAt":"2026-08-21T14:25:43.473Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}