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

  1. Add gem 'json' to your Gemfile and bundle install
  2. Use gem 'json_pure' as an alternative pure-Ruby parser
  3. Ensure ActiveSupport is loaded (e.g. in Rails apps json is available transitively)
  4. 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

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


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)