{"record":{"id":"c6fd701c95551b61","repo":"alexreisner/geocoder","slug":"could-not-load-ip2location-db-dependency-to-use-the","errorCode":null,"errorMessage":"Could not load IP2Location DB dependency. To use the IP2LocationLite lookup you must add the #{@gem_name} gem to your Gemfile or have it installed in your system.","messagePattern":"Could not load IP2Location DB dependency\\. To use the IP2LocationLite lookup you must add the #(.+?) gem to your Gemfile or have it installed in your system\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"lib/geocoder/lookups/ip2location_lite.rb","lineNumber":15,"sourceCode":"require 'geocoder/lookups/base'\nrequire 'geocoder/results/ip2location_lite'\n\nmodule Geocoder\n  module Lookup\n    class Ip2locationLite < Base\n      attr_reader :gem_name\n\n      def initialize\n        unless configuration[:file].nil?\n          begin\n            @gem_name = 'ip2location_ruby'\n            require @gem_name\n          rescue LoadError\n            raise \"Could not load IP2Location DB dependency. To use the IP2LocationLite lookup you must add the #{@gem_name} gem to your Gemfile or have it installed in your system.\"\n          end\n        end\n        super\n      end\n\n      def name\n        'IP2LocationLite'\n      end\n\n      def required_api_key_parts\n        []\n      end\n\n      private\n\n      def results(query)\n        return [] unless configuration[:file]\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/alexreisner/geocoder/blob/c10bd701215110ebe65da1c8b8b410b124208fd2/lib/geocoder/lookups/ip2location_lite.rb#L1-L33","documentation":"The IP2LocationLite lookup's initializer requires the ip2location_ruby gem when a local database :file is configured; a LoadError is re-raised as a descriptive message because the lookup depends on that gem to read the BIN file.","triggerScenarios":"Geocoder.configure(lookup: :ip2location_lite, file: 'IP2LOCATION-LITE-DB1.BIN') without gem 'ip2location_ruby' installed or bundled.","commonSituations":"New machine/CI image without the gem, forgetting bundle install after adding the lookup, gem only in a group excluded from production.","solutions":["Add gem 'ip2location_ruby' to your Gemfile and bundle install","Verify installation with `gem list ip2location_ruby`","Ensure the gem is available in the deployment environment (not gated behind a group)","Alternatively switch to an HTTP-based lookup that needs no local DB gem"],"exampleFix":"// before\n# Gemfile: (missing)\n// after\ngem 'ip2location_ruby'","handlingStrategy":"validation","validationCode":"begin; require 'ip2location_ruby'; rescue LoadError; abort \"gem 'ip2location_ruby' required\"; end","typeGuard":null,"tryCatchPattern":"begin\n  Geocoder.search(ip)\nrescue LoadError => e\n  abort \"IP2Location dependency missing: #{e.message}\"\nend","preventionTips":["Add gem 'ip2location_ruby' to the Gemfile","Run bundle install in CI and deploys","Confirm gem availability on the target platform"],"tags":["ruby","dependency","ip2location"],"backgroundTag":"missing-dependency","analyzedSha":"c10bd701215110ebe65da1c8b8b410b124208fd2","analyzedAt":"2026-09-15T23:43:32.125Z","contentChangedAt":"2026-09-15T23:43:32.125Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}