alexreisner/geocoder · error · LoadError
Please install the 'json' or 'json_pure' gem to parse…
Error message
Please install the 'json' or 'json_pure' gem to parse geocoder results.
What it means
At load time, if ActiveSupport::JSON is not defined, geocoder/lookups/base.rb requires 'json' and converts a LoadError into a descriptive LoadError telling the developer to install the json or json_pure gem, since result parsing depends on it.
Solutions
- Add gem 'json' to your Gemfile and bundle install
- Use gem 'json_pure' as an alternative pure-Ruby parser
- Ensure ActiveSupport is loaded (e.g. in Rails apps json is available transitively)
- Upgrade Ruby to a version where json is part of the stdlib
Example fix
// Gemfile before # (no json gem) // after gem 'json'
Defensive patterns
Strategy: fallback
Validate before calling
begin; require 'json'; rescue LoadError; abort 'install json gem'; end
Try / catch
begin
require 'geocoder'
rescue LoadError => e
abort "#{e.message} — add gem 'json'"
end Prevention
- Always include gem 'json' (or run under Rails/ActiveSupport)
- Smoke-test `require 'geocoder'` in CI on a bare Ruby image
- Keep Ruby version modern where json ships by default
When it happens
Trigger: Requiring geocoder in a Ruby environment without the json gem and without ActiveSupport loaded (e.g. minimal gemfile, old Ruby without bundled json, JRuby setup missing json_pure).
Common situations: Old Ruby versions (<1.9) lacking built-in json, trimmed production deployments, or projects that removed json from the Gemfile.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Could not load geoip dependency. To use MaxMind Local…
- Could not load IP2Location DB dependency. To use the…
- Could not load Maxmind DB dependency. To use the GeoIP2…
- Error parsing # proxy URL: '#
- Geocoder tried to log a message with an invalid log level.
AI-assisted analysis of alexreisner/geocoder@c10bd70121 (2026-09-15).
Data as JSON: /api/errors/5de60d7e4664f920.
Report an issue: GitHub.
Appendix: source
Thrown at lib/geocoder/lookups/base.rb:9
require 'net/http'
require 'net/https'
require 'uri'
unless defined?(ActiveSupport::JSON)
begin
require 'json'
rescue LoadError
raise LoadError, "Please install the 'json' or 'json_pure' gem to parse geocoder results."
end
end
module Geocoder
module Lookup
class Base
def initialize
@cache = nil
end
##
# Human-readable name of the geocoding API.
#
def name
fail
end
View on GitHub (pinned to c10bd70121)