diff --git a/lib/ruby_indexer/lib/ruby_indexer/configuration.rb b/lib/ruby_indexer/lib/ruby_indexer/configuration.rb index 2c9a658718..fa1981a176 100644 --- a/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +++ b/lib/ruby_indexer/lib/ruby_indexer/configuration.rb @@ -273,7 +273,13 @@ def initial_excluded_gems end others.concat(this_gem.to_spec.dependencies) if this_gem - others.concat(others.filter_map { |d| d.to_spec&.dependencies }.flatten) + others.concat( + others.filter_map do |d| + d.to_spec&.dependencies + rescue Gem::MissingSpecError + false + end.flatten, + ) others.uniq! others.map!(&:name) diff --git a/lib/ruby_indexer/test/configuration_test.rb b/lib/ruby_indexer/test/configuration_test.rb index 13f525c9a8..a4b6487023 100644 --- a/lib/ruby_indexer/test/configuration_test.rb +++ b/lib/ruby_indexer/test/configuration_test.rb @@ -204,5 +204,36 @@ def test_transitive_dependencies_for_non_dev_gems_are_not_excluded end end end + + def test_does_not_fail_if_there_are_missing_specs_due_to_platform_constraints + Dir.mktmpdir do |dir| + Dir.chdir(dir) do + File.write(File.join(dir, "Gemfile"), <<~RUBY) + source "https://rubygems.org" + gem "ruby-lsp", path: "#{Bundler.root}" + + platforms :windows do + gem "tzinfo" + gem "tzinfo-data" + end + RUBY + + Bundler.with_unbundled_env do + capture_subprocess_io { system("bundle install") } + + _stdout, stderr = capture_subprocess_io do + script = [ + "require \"ruby_lsp/internal\"", + "RubyIndexer::Configuration.new.indexable_uris", + ].join(";") + + system("bundle exec ruby -e '#{script}'") + end + + assert_empty(stderr) + end + end + end + end end end