{"record":{"id":"fc56303c713c3ada","repo":"ruby/ruby","slug":"unable-to-find-name","errorCode":null,"errorMessage":"Unable to find '#{name}'","messagePattern":"Unable to find '#(.+?)'","errorType":"exception","errorClass":"Gem::Exception","httpStatus":null,"severity":"error","filePath":"lib/rubygems/source/specific_file.rb","lineNumber":36,"sourceCode":"    @path = ::File.expand_path(file)\n\n    @package = Gem::Package.new @path\n    @spec = @package.spec\n    @name = @spec.name_tuple\n  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+.","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/ruby/ruby/blob/0e5b888e1c355f3f728f2659f085820937dada48/lib/rubygems/source/specific_file.rb#L18-L54","documentation":"Gem::Source::SpecificFile wraps exactly one .gem file; fetch_spec answers only for its own name tuple (@name) and raises for any other. Hitting it means the resolver/caller asked this single-file source for a gem it cannot possibly serve — e.g. a dependency was routed to the SpecificFile source of an unrelated gem, or the tuple (platform/version) differs from the file's.","triggerScenarios":"gem install ./foo.gem (or custom resolvers using SpecificFile) where a transitive dependency gets resolved against this source; tuple mismatch such as requesting the \"ruby\" platform tuple while the file provides x86_64-linux (or vice versa); name differences after renaming a gem.","commonSituations":"Installing a .gem with unmet dependencies using local-only sources; custom installer code that mixes one SpecificFile into the source list; platform-specific .gem files requested with a different platform tuple.","solutions":["Provide a source that can serve the requested gem: add the default remote source, or wrap the dependency's own .gem in its own Gem::Source::SpecificFile","Compare tuples before calling: source.load_specs.first vs. the requested name/version/platform, and fix mismatches","Install dependencies first (gem install dep -v x.y.z) so nothing needs to be fetched from the single-file source"],"exampleFix":"# before\nspecific = Gem::Source::SpecificFile.new(\"foo-1.0.gem\")\nspecific.fetch_spec(Gem::NameTuple.new(\"bar\", Gem::Version.new(\"2.0\"), \"ruby\")) #=> Unable to find 'bar'\n\n# after: only ask a source for what it holds\nfoo_tuple = specific.load_specs.first\nspecific.fetch_spec(foo_tuple)  # => foo's spec","handlingStrategy":"validation","validationCode":"specific = Gem::Source::SpecificFile.new(\"foo-1.0.gem\")\nowned = specific.load_specs.first  # the one tuple this source serves\nraise \"this source only provides #{owned.full_name}\" unless name == owned\nspecific.fetch_spec(name)","typeGuard":"def specific_file_serves?(source, name_tuple)\n  source.load_specs.first == name_tuple\nend","tryCatchPattern":null,"preventionTips":["Ask a SpecificFile source only for its own tuple (source.load_specs.first); route everything else to remote/local sources","When installing a .gem with dependencies, make sure a remote or local source is also in play for those dependencies","Verify the .gem filename encodes the exact name-version-platform you intend to request"],"tags":["rubygems","specific-file-source","dependency-resolution","name-tuple"],"backgroundTag":"package-not-found","analyzedSha":"0e5b888e1c355f3f728f2659f085820937dada48","analyzedAt":"2026-08-21T14:25:43.473Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}