jdx/mise · error · TypeError

cannot encode #{value.class} as JSON

Error message

cannot encode #{value.class} as JSON

What it means

mise's HTTP client checks the `offline` setting before every outgoing GET. When offline mode is enabled, get_async_with_headers refuses to issue any network request and throws "offline mode is enabled". This is an intentional guard so mise performs no network I/O when the user has opted into offline behavior.

Source

Thrown at src/system/packages/brew/tap_formula_metadata.rb:31

    when String
      '"' + value.each_codepoint.map { |codepoint|
        case codepoint
        when 0x08 then "\\b"
        when 0x09 then "\\t"
        when 0x0a then "\\n"
        when 0x0c then "\\f"
        when 0x0d then "\\r"
        when 0x22 then '\\"'
        when 0x5c then "\\\\"
        when 0...0x20 then format("\\u%04x", codepoint)
        else codepoint.chr("UTF-8")
        end
      }.join + '"'
    when Numeric then value.to_s
    when true then "true"
    when false then "false"
    when nil then "null"
    else raise TypeError, "cannot encode #{value.class} as JSON"
    end
  end
end

FORMULA_FILE = ENV.fetch("MISE_BREW_SOURCE_PATH")
FORMULA_NAME = ENV.fetch("MISE_BREW_NAME")

module OS
  def self.mac? = ENV.fetch("MISE_BREW_OS") == "macos"
  def self.linux? = ENV.fetch("MISE_BREW_OS") == "linux"
end

class MacOSVersion
  include Comparable

  SYMBOLS = {
    tahoe: "26", sequoia: "15", sonoma: "14", ventura: "13",
    monterey: "12", big_sur: "11", catalina: "10.15", mojave: "10.14",

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Unset MISE_OFFLINE or set it to a falsy value, then retry
  2. Set `offline = false` under [settings] in mise.toml / global settings
  3. Run `mise settings set offline false`
  4. Pre-cache needed artifacts while online, or use already-installed tool versions

Example fix

// before
MISE_OFFLINE=1 mise install node@22

// after
unset MISE_OFFLINE
mise install node@22
Defensive patterns

Strategy: try-catch

Validate before calling

// shell
[ "${MISE_OFFLINE:-0}" = "0" ] || echo "offline mode on; network GET will fail"

Try / catch

match result {
    Err(e) if e.to_string().contains("offline mode is enabled") => fallback_to_cached(),
    other => other?,
}

Prevention

When it happens

Trigger: Calling get_async_with_headers (any HTTPClient GET) while Settings::get().offline() is true — e.g. `MISE_OFFLINE=1` or `offline = true` in settings, combined with any operation that fetches over HTTP.

Common situations: User left MISE_OFFLINE=1 exported in their shell and then tries to install/list tool versions; CI set offline mode for determinism but a step still needs a remote lookup.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/e7f4ab3e7088cb92. Report an issue: GitHub.