lib/ruby_indexer/lib/ruby_indexer/configuration.rb in ruby-lsp-0.13.4 vs lib/ruby_indexer/lib/ruby_indexer/configuration.rb in ruby-lsp-0.14.0
- old
+ new
@@ -190,10 +190,13 @@
dependency.groups == [:development]
end
# When working on a gem, we need to make sure that its gemspec dependencies can't be excluded. This is necessary
# because Bundler doesn't assign groups to gemspec dependencies
+ #
+ # If the dependency is prerelease, `to_spec` may return `nil` due to a bug in older version of Bundler/RubyGems:
+ # https://github.com/Shopify/ruby-lsp/issues/1246
this_gem = Bundler.definition.dependencies.find do |d|
d.to_spec&.full_gem_path == Dir.pwd
rescue Gem::MissingSpecError
false
end
@@ -201,20 +204,19 @@
others.concat(this_gem.to_spec.dependencies) if this_gem
excluded.each do |dependency|
next unless dependency.runtime?
- # If the dependency is prerelease, to_spec may return `nil`
spec = dependency.to_spec
next unless spec
spec.dependencies.each do |transitive_dependency|
# If the transitive dependency is included in other groups, skip it
next if others.any? { |d| d.name == transitive_dependency.name }
# If the transitive dependency is included as a transitive dependency of a gem outside of the development
# group, skip it
- next if others.any? { |d| d.to_spec.dependencies.include?(transitive_dependency) }
+ next if others.any? { |d| d.to_spec&.dependencies&.include?(transitive_dependency) }
excluded << transitive_dependency
end
rescue Gem::MissingSpecError
# If a gem is scoped only to some specific platform, then its dependencies may not be installed either, but they