Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when when no platform specific matches exist and show a proper error #5168

Merged

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Dec 15, 2021

What was the end-user or developer problem that led to this PR?

When a gem only has platform specific variants and none of them matches the current platform, the resolver would incorrectly allow this case, and we would get an error later down the line since that specific gem can't be materialized.

See #5088 (comment).

What is your fix for the problem, implemented in this PR?

My fix is to properly detect this case and don't consider any candidates suffering from this problem, resulting in a proper resolution error rather than a crash.

Also took the chance to improve the error message in this case.

So, now, instead of the previous output with a runtime crash and the bug report template, we get an informative message, like this

$ bundle install
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Bundler could not find compatible versions for gem "sorbet-static":
  In Gemfile:
    sorbet (= 0.5.6433) was resolved to 0.5.6433, which depends on
      sorbet-static (= 0.5.6433)

Could not find gem 'sorbet-static (= 0.5.6433) arm64-darwin-21', which is required by gem 'sorbet (= 0.5.6433)', in rubygems repository https://rubygems.org/ or installed locally.

The source contains the following gems matching 'sorbet-static (= 0.5.6433)':
  * sorbet-static-0.5.6433-java
  * sorbet-static-0.5.6433-universal-darwin-14
  * sorbet-static-0.5.6433-universal-darwin-15
  * sorbet-static-0.5.6433-universal-darwin-16
  * sorbet-static-0.5.6433-universal-darwin-17
  * sorbet-static-0.5.6433-universal-darwin-18
  * sorbet-static-0.5.6433-universal-darwin-19
  * sorbet-static-0.5.6433-universal-darwin-20
  * sorbet-static-0.5.6433-x86_64-linux

Make sure the following tasks are checked

@deivid-rodriguez deivid-rodriguez changed the title Fix resolver when no platform specific matches exist Fix crash when no platform specific matches exist Dec 15, 2021
@deivid-rodriguez deivid-rodriguez force-pushed the fix_resolver_when_no_platform_specific_matches_exist branch from 2c9c991 to bf1bf59 Compare December 15, 2021 10:46
If we are resolving a dependency against a particular platform, and
there are no platform specific variants of the candidates that match
that platform, we should not consider those candidates.
@deivid-rodriguez deivid-rodriguez force-pushed the fix_resolver_when_no_platform_specific_matches_exist branch from bf1bf59 to f481e8f Compare December 15, 2021 12:33
@deivid-rodriguez deivid-rodriguez marked this pull request as ready for review December 15, 2021 12:47
@deivid-rodriguez deivid-rodriguez changed the title Fix crash when no platform specific matches exist Better error when no platform specific matches exist Dec 15, 2021
@deivid-rodriguez deivid-rodriguez changed the title Better error when no platform specific matches exist Fix crash when when no platform specific matches exist and show a proper error Dec 15, 2021
@deivid-rodriguez deivid-rodriguez merged commit 1204bbe into master Dec 17, 2021
@deivid-rodriguez deivid-rodriguez deleted the fix_resolver_when_no_platform_specific_matches_exist branch December 17, 2021 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants