Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/solargraph/gem_pins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def self.combine_method_pins(*pins)
# @return [Array<Pin::Base>]
def self.build_yard_pins(yard_plugins, gemspec)
Yardoc.cache(yard_plugins, gemspec) unless Yardoc.cached?(gemspec)
return [] unless Yardoc.cached?(gemspec)
yardoc = Yardoc.load!(gemspec)
YardMap::Mapper.new(yardoc, gemspec).map
end
Expand Down
9 changes: 9 additions & 0 deletions lib/solargraph/yardoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ def cache(yard_plugins, gemspec)
path = PinCache.yardoc_path gemspec
return path if cached?(gemspec)

unless Dir.exist? gemspec.gem_dir
# Can happen in at least some (old?) RubyGems versions when we
# have a gemspec describing a standard library like bundler.
#
# https://github.com/apiology/solargraph/actions/runs/17650140201/job/50158676842?pr=10
Solargraph.logger.info { "Bad info from gemspec - #{gemspec.gem_dir} does not exist" }
return path
end

Solargraph.logger.info "Caching yardoc for #{gemspec.name} #{gemspec.version}"
cmd = "yardoc --db #{path} --no-output --plugin solargraph"
yard_plugins.each { |plugin| cmd << " --plugin #{plugin}" }
Expand Down
5 changes: 5 additions & 0 deletions spec/gem_pins_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
expect(core_root.return_type.to_s).to eq('Pathname, nil')
expect(core_root.location.filename).to end_with('environment_loader.rb')
end

it 'does not error out when handed incorrect gemspec' do
gemspec = instance_double(Gem::Specification, name: 'foo', version: '1.0', gem_dir: '/not-there')
expect { Solargraph::GemPins.build_yard_pins([], gemspec) }.not_to raise_error
end
end
Loading