{"record":{"id":"eff69b1a5fb2824f","repo":"alexreisner/geocoder","slug":"could-not-load-geoip-dependency-to-use-maxmind-local-lookup","errorCode":null,"errorMessage":"Could not load geoip dependency. To use MaxMind Local lookup you must add the #{gem} gem to your Gemfile or have it installed in your system.","messagePattern":"Could not load geoip dependency\\. To use MaxMind Local 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/maxmind_local.rb","lineNumber":14,"sourceCode":"require 'ipaddr'\nrequire 'geocoder/lookups/base'\nrequire 'geocoder/results/maxmind_local'\n\nmodule Geocoder::Lookup\n  class MaxmindLocal < Base\n\n    def initialize\n      if !configuration[:file].nil?\n        begin\n          gem = RUBY_PLATFORM == 'java' ? 'jgeoip' : 'geoip'\n          require gem\n        rescue LoadError\n          raise \"Could not load geoip dependency. To use MaxMind Local lookup you must add the #{gem} gem to your Gemfile or have it installed in your system.\"\n        end\n      end\n      super\n    end\n\n    def name\n      \"MaxMind Local\"\n    end\n\n    def required_api_key_parts\n      []\n    end\n\n    private\n\n    def results(query)\n      if configuration[:file]\n        geoip_class = RUBY_PLATFORM == \"java\" ? JGeoIP : GeoIP","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/alexreisner/geocoder/blob/c10bd701215110ebe65da1c8b8b410b124208fd2/lib/geocoder/lookups/maxmind_local.rb#L1-L32","documentation":"The MaxMind Local lookup requires the geoip gem (or jgeoip on JRuby) when a local :file is configured; a LoadError is re-raised as a descriptive message since it cannot read the local database without that dependency.","triggerScenarios":"Geocoder.configure(lookup: :maxmind_local, file: 'GeoLiteCity.dat') without the geoip gem installed (MRI) or jgeoip (JRuby), detected via RUBY_PLATFORM.","commonSituations":"Running the app under JRuby where only the 'geoip' gem is bundled (needs jgeoip), or under MRI where only jgeoip is present; fresh deploys missing the gem.","solutions":["Add gem 'geoip' to your Gemfile (MRI) and bundle install","On JRuby add gem 'jgeoip' instead","Check RUBY_PLATFORM in your environment to know which gem is required","Ensure the gem is in a group included in production"],"exampleFix":"// before\n# Gemfile (JRuby): gem 'geoip'\n// after\n# Gemfile (JRuby): gem 'jgeoip'","handlingStrategy":"validation","validationCode":"gem_name = RUBY_PLATFORM == 'java' ? 'jgeoip' : 'geoip'\nbegin; require gem_name; rescue LoadError; abort \"#{gem_name} gem required\"; end","typeGuard":null,"tryCatchPattern":"begin\n  Geocoder.search(ip)\nrescue LoadError => e\n  abort \"MaxMind Local dependency missing: #{e.message}\"\nend","preventionTips":["Bundle 'geoip' on MRI and 'jgeoip' on JRuby","Condition gem selection on platform in the Gemfile","Verify require succeeds at application boot"],"tags":["ruby","dependency","maxmind","geoip"],"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"}