{"record":{"id":"573f9b0cfbf71fef","repo":"ruby/rubygems","slug":"4-573f9b","errorCode":"4","errorMessage":"`#{gem_name}` is not specified in #{gemfile_path} so it could not be removed.","messagePattern":"`#(.+?)` is not specified in #(.+?) so it could not be removed\\.","errorType":"exception","errorClass":"Bundler::GemfileError","httpStatus":null,"severity":"error","filePath":"lib/bundler/injector.rb","lineNumber":172,"sourceCode":"      # check for errors\n      # including extra gems being removed\n      # or some gems not being removed\n      # and return the actual removed deps\n      cross_check_for_errors(gemfile_path, builder.dependencies, removed_deps, initial_gemfile)\n    end\n\n    # @param [Dsl]      builder Dsl object of current Gemfile.\n    # @param [Array]    gems Array of names of gems to be removed.\n    # @param [Pathname] gemfile_path Path of the Gemfile.\n    # @return [Array]   Array of removed dependencies.\n    def remove_gems_from_dependencies(builder, gems, gemfile_path)\n      removed_deps = []\n\n      gems.each do |gem_name|\n        deleted_dep = builder.dependencies.find {|d| d.name == gem_name }\n\n        if deleted_dep.nil?\n          raise GemfileError, \"`#{gem_name}` is not specified in #{gemfile_path} so it could not be removed.\"\n        end\n\n        builder.dependencies.delete(deleted_dep)\n\n        removed_deps << deleted_dep\n      end\n\n      removed_deps\n    end\n\n    # @param [Array] gems            Array of names of gems to be removed.\n    # @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.\n    def remove_gems_from_gemfile(gems, gemfile_path)\n      patterns = /gem\\s+(['\"])#{Regexp.union(gems)}\\1|gem\\s*\\((['\"])#{Regexp.union(gems)}\\2.*\\)/\n      new_gemfile = []\n      multiline_removal = false\n      File.readlines(gemfile_path).each do |line|\n        match_data = line.match(patterns)","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/bundler/injector.rb#L154-L190","documentation":"Error \"`#{gem_name}` is not specified in #{gemfile_path} so it could not be removed.\" thrown in ruby/rubygems.","triggerScenarios":"Thrown at lib/bundler/injector.rb:172 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"}