{"record":{"id":"a8a1b1e34a26c702","repo":"ruby/ruby","slug":"two-gemspec-development-dependencies-have-conflict","errorCode":null,"errorMessage":"Two gemspec development dependencies have conflicting requirements on the same gem: #{dep} and #{current}","messagePattern":"Two gemspec development dependencies have conflicting requirements on the same gem: #(.+?) and #(.+?)","errorType":"exception","errorClass":"GemfileError","httpStatus":null,"severity":"error","filePath":"lib/bundler/dsl.rb","lineNumber":347,"sourceCode":"        if current.requirement != dep.requirement\n          current_requirement_open = current.requirements_list.include?(\">= 0\")\n\n          gemspec_dep = [dep, current].find(&:gemspec_dev_dep?)\n          if gemspec_dep\n            require_relative \"vendored_pub_grub\"\n\n            current_gemspec_range = Gem::PubGrub::RubyGems.requirement_to_range(current.requirement)\n            next_gemspec_range = Gem::PubGrub::RubyGems.requirement_to_range(dep.requirement)\n\n            if current_gemspec_range.intersects?(next_gemspec_range)\n              dep = Dependency.new(name, current.requirement.as_list + dep.requirement.as_list, options)\n            else\n              gemfile_dep = [dep, current].find(&:gemfile_dep?)\n\n              if gemfile_dep\n                raise GemfileError, \"The #{name} dependency has conflicting requirements in Gemfile (#{gemfile_dep.requirement}) and gemspec (#{gemspec_dep.requirement})\"\n              else\n                raise GemfileError, \"Two gemspec development dependencies have conflicting requirements on the same gem: #{dep} and #{current}\"\n              end\n            end\n          else\n            update_prompt = \"\"\n\n            if File.basename(@gemfile) == Injector::INJECTED_GEMS\n              if dep.requirements_list.include?(\">= 0\") && !current_requirement_open\n                update_prompt = \". Gem already added\"\n              else\n                update_prompt = \". If you want to update the gem version, run `bundle update #{name}`\"\n\n                update_prompt += \". You may also need to change the version requirement specified in the Gemfile if it's too restrictive.\" unless current_requirement_open\n              end\n            end\n\n            raise GemfileError, \"You cannot specify the same gem twice with different version requirements.\\n\" \\\n                           \"You specified: #{name} (#{current.requirement}) and #{name} (#{dep.requirement})\" \\\n                           \"#{update_prompt}\"","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/ruby/ruby/blob/0e5b888e1c355f3f728f2659f085820937dada48/lib/bundler/dsl.rb#L329-L365","documentation":"Same merging path as the Gemfile/gemspec conflict, but here BOTH conflicting requirements come from gemspec development dependencies (lib/bundler/dsl.rb:347): the parsed gemspec ends up with two development dependency entries for one gem whose PubGrub ranges do not intersect, and neither is a Gemfile dep, so the GemfileError names the two Dependency objects directly. Bundler refuses to pick between contradictory constraints inside a single gemspec.","triggerScenarios":"One .gemspec containing two `spec.add_development_dependency \"rake\", ...` calls with disjoint ranges (e.g. \">= 13\" and \"< 13\"), typically after editing a version and forgetting the older line; also gemspecs generated by concatenating conditionals that both add the same gem differently.","commonSituations":"Gem under active development where a dev-tool version was changed by adding a new add_development_dependency instead of editing the existing one; gems with platform-conditional gemspec blocks each declaring the same dev dep with different pins.","solutions":["Grep the gemspec for the gem name shown in the message and delete the stale add_development_dependency line","If both lines must stay (conditional blocks), make their requirement ranges intersect","Run `gem build yourgem.gemspec` or `bundle install` again to confirm the gemspec now parses to a single consistent requirement"],"exampleFix":"# before (mygem.gemspec)\nspec.add_development_dependency \"rspec\", \"~> 3.12\"\nspec.add_development_dependency \"rspec\", \"~> 4.0\" # conflicting\n\n# after\nspec.add_development_dependency \"rspec\", \"~> 3.12\"","handlingStrategy":"validation","validationCode":"# Fail fast when a gemspec declares the same dev gem twice\ndeps = {}\nspec = Gem::Specification.load(\"mygem.gemspec\")\nspec.development_dependencies.map(&:name).tally.each do |name, count|\n  abort \"gemspec declares #{name} #{count} times\" if count > 1\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Before adding a dev dependency, search the gemspec for the gem name","Edit existing add_development_dependency lines instead of appending new ones for the same gem","Generate gemspecs from a single dependency list rather than concatenating conditional blocks"],"tags":["ruby","bundler","gemspec","version-conflict","dependencies","duplicates"],"backgroundTag":"dependency-version-conflict","analyzedSha":"0e5b888e1c355f3f728f2659f085820937dada48","analyzedAt":"2026-08-21T14:25:43.473Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}