ruby/ruby · error · ArgumentError

#{digest.inspect} is not a valid SHA256 hex or base64 digest

Error message

#{digest.inspect} is not a valid SHA256 hex or base64 digest

What it means

Error "#{digest.inspect} is not a valid SHA256 hex or base64 digest" thrown in ruby/ruby.

Source

Thrown at lib/bundler/checksum.rb:50

        return if Bundler.settings[:disable_checksum_validation]

        Checksum.new(algo, to_hexdigest(digest, algo), Source.new(:api, source_uri))
      end

      def from_lock(lock_checksum, lockfile_location)
        algo, digest = lock_checksum.strip.split(ALGO_SEPARATOR, 2)
        Checksum.new(algo, to_hexdigest(digest, algo), Source.new(:lock, lockfile_location))
      end

      def to_hexdigest(digest, algo = DEFAULT_ALGORITHM)
        return digest unless algo == DEFAULT_ALGORITHM
        return digest if digest.match?(/\A[0-9a-f]{64}\z/i)

        if digest.match?(%r{\A[-0-9a-z_+/]{43}={0,2}\z}i)
          digest = digest.tr("-_", "+/") # fix urlsafe base64
          digest.unpack1("m0").unpack1("H*")
        else
          raise ArgumentError, "#{digest.inspect} is not a valid SHA256 hex or base64 digest"
        end
      end
    end

    attr_reader :algo, :digest, :sources

    def initialize(algo, digest, source)
      @algo = algo
      @digest = digest
      @sources = [source]
    end

    def ==(other)
      match?(other) && other.sources == sources
    end

    alias_method :eql?, :==

View on GitHub (pinned to 0e5b888e1c)

When it happens

Trigger: Thrown at lib/bundler/checksum.rb:50 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruby/ruby@0e5b888e1c (2026-08-21). Data as JSON: /api/errors/ff834d6f2bfaec31. Report an issue: GitHub.