{"record":{"id":"e116998580b5e1d6","repo":"ruby/ruby","slug":"unable-to-download-spec-full-name","errorCode":null,"errorMessage":"Unable to download '#{spec.full_name}'","messagePattern":"Unable to download '#(.+?)'","errorType":"exception","errorClass":"Gem::Exception","httpStatus":null,"severity":"error","filePath":"lib/rubygems/source/specific_file.rb","lineNumber":41,"sourceCode":"  end\n\n  ##\n  # The Gem::Specification extracted from this .gem.\n\n  attr_reader :spec\n\n  def load_specs(*a) # :nodoc:\n    [@name]\n  end\n\n  def fetch_spec(name) # :nodoc:\n    return @spec if name == @name\n    raise Gem::Exception, \"Unable to find '#{name}'\"\n  end\n\n  def download(spec, dir = nil) # :nodoc:\n    return @path if spec == @spec\n    raise Gem::Exception, \"Unable to download '#{spec.full_name}'\"\n  end\n\n  def pretty_print(q) # :nodoc:\n    q.object_group(self) do\n      q.group 2, \"[SpecificFile:\", \"]\" do\n        q.breakable\n        q.text @path\n      end\n    end\n  end\n\n  ##\n  # Orders this source against +other+.\n  #\n  # If +other+ is a SpecificFile from a different gem name +nil+ is returned.\n  #\n  # If +other+ is a SpecificFile from the same gem name the versions are\n  # compared using Gem::Version#<=>","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/ruby/ruby/blob/0e5b888e1c355f3f728f2659f085820937dada48/lib/rubygems/source/specific_file.rb#L23-L59","documentation":"Gem::Source::SpecificFile#download returns the wrapped file's path only when the passed spec == @spec, and Gem::Specification#== compares class plus name, version, and platform. The error means the spec handed to download describes a different gem (or a different version/platform) than the .gem file this source wraps — most often a dependency's spec routed to the wrong source.","triggerScenarios":"source.download(spec) where spec was resolved elsewhere (a dependency's spec) rather than the spec parsed from the wrapped .gem; version/platform differences between the requested spec and the file's spec.","commonSituations":"Custom installers/resolvers iterating sources and calling download with each candidate spec; platform mixups (requesting the ruby platform spec for a x86_64-linux .gem); version skew after rebuilding a gem without updating the caller.","solutions":["Call download with the source's own spec: src.download(src.spec)","Guard before calling: skip the source unless spec == src.spec, and route other specs to sources that actually hold them","For plain installs, use gem install ./foo-1.0.gem and let RubyGems pick dependencies from proper sources"],"exampleFix":"# before\nspecific = Gem::Source::SpecificFile.new(\"foo-1.0.gem\")\nspecific.download(resolved_bar_spec)  #=> Unable to download 'bar-2.0'\n\n# after\ncached = sources.find {|s| s.is_a?(Gem::Source::SpecificFile) && s.spec == spec }\npath = cached ? cached.download(spec) : remote_source.download(spec)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"# Gem::Specification#== compares name, version, platform (specification.rb)\ndef specific_file_holds?(source, spec)\n  spec.is_a?(Gem::Specification) && spec == source.spec\nend\npath = specific_file_holds?(src, spec) ? src.download(spec) : nil","tryCatchPattern":null,"preventionTips":["Guard downloads with spec == source.spec before calling SpecificFile#download; only its own spec is accepted","In custom resolvers, iterate sources and skip ones whose wrapped spec does not equal the requested spec","Pass the source's own spec (source.spec) when you just need the file path for that gem"],"tags":["rubygems","specific-file-source","download","spec-mismatch"],"backgroundTag":"package-file-mismatch","analyzedSha":"0e5b888e1c355f3f728f2659f085820937dada48","analyzedAt":"2026-08-21T14:25:43.473Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}