{"record":{"id":"98833824a039fc8a","repo":"ruby/rubygems","slug":"15-988338","errorCode":"15","errorMessage":"Gems could not be removed. #{extra_removed_gems.join(\", \")} would also have been removed. Bundler cannot continue.","messagePattern":"Gems could not be removed\\. #(.+?) would also have been removed\\. Bundler cannot continue\\.","errorType":"exception","errorClass":"Bundler::InvalidOption","httpStatus":null,"severity":"error","filePath":"lib/bundler/injector.rb","lineNumber":262,"sourceCode":"\n    # @param [Pathname] gemfile_path   The Gemfile from which to remove dependencies.\n    # @param [Array] original_deps     Array of original dependencies.\n    # @param [Array] removed_deps      Array of removed dependencies.\n    # @param [Array] initial_gemfile   Contents of original Gemfile before any operation.\n    def cross_check_for_errors(gemfile_path, original_deps, removed_deps, initial_gemfile)\n      # evaluate the new gemfile to look for any failure cases\n      builder = Dsl.new\n      builder.eval_gemfile(gemfile_path)\n\n      # record gems which were removed but not requested\n      extra_removed_gems = original_deps - builder.dependencies\n\n      # if some extra gems were removed then raise error\n      # and revert Gemfile to original\n      unless extra_removed_gems.empty?\n        SharedHelpers.write_to_gemfile(gemfile_path, initial_gemfile.join)\n\n        raise InvalidOption, \"Gems could not be removed. #{extra_removed_gems.join(\", \")} would also have been removed. Bundler cannot continue.\"\n      end\n\n      # record gems which could not be removed due to some reasons\n      errored_deps = builder.dependencies.select {|d| d.gemfile == gemfile_path } & removed_deps.select {|d| d.gemfile == gemfile_path }\n\n      show_warning \"#{errored_deps.map(&:name).join(\", \")} could not be removed.\" unless errored_deps.empty?\n\n      # return actual removed dependencies\n      removed_deps - errored_deps\n    end\n\n    def show_warning(message)\n      Bundler.ui.info Bundler.ui.add_color(message, :yellow)\n    end\n\n    def convert_autorequire(autorequire)\n      autorequire = autorequire.first\n      return autorequire if autorequire == \"false\"","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/bundler/injector.rb#L244-L280","documentation":"Error \"Gems could not be removed. #{extra_removed_gems.join(\", \")} would also have been removed. Bundler cannot continue.\" thrown in ruby/rubygems.","triggerScenarios":"Thrown at lib/bundler/injector.rb:262 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"}