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 install crash when lockfile has missing dependencies for the current platform #4941

Merged
merged 4 commits into from
Oct 13, 2021

Conversation

deivid-rodriguez
Copy link
Member

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

Running bundle install on a lockfile apparently generated with new rails applications causes bundler to crash.

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

My fix is to refactor Definition to make sure that the case of missing gems in the lockfile for the current platform is properly detected and a re-resolve is triggered to fix the situation.

Fixes #4922.

Make sure the following tasks are checked

@deivid-rodriguez deivid-rodriguez force-pushed the fix_install_crash branch 3 times, most recently from 07ca584 to 98bf184 Compare September 29, 2021 19:36
It doesn't really need converged specs, since it's only about the
lockfile.
This is exclusively about the lockfile.
In case we have a corrupted lockfile that claims to support a platform, but
it's missing platform specific gems for it, bundler has a check that
detects the situation and forces a re-resolve. The result of this check
is kept under the `@locked_specs_incomplete_for_platformn` instance
variable in `Definition`.

The installer, however, calls `Definition#nothing_changed?` before this
instance variable has been filled, so the result of it is actually
incorrect here since it will claim that nothing has changed, but
something has changed (locked specs are incomplete for the current
platform).

The consequence of this incorrect result is that the installer thinks it
can go on without re-resolving, resulting in the incomplete resolution
from the lockfile being used, and in a crash being triggered due to
that.

The solution is to make sure the `@locked_specs_incomplete_for_platform`
instance variable is filled before `nothing_changed?` gets called.
Moving it to `initialize` makes the most sense, not because it's the
best place for it (we can refactor this later), but because all of the
other "outdated definition" checks are already set there.
@deivid-rodriguez deivid-rodriguez marked this pull request as ready for review October 13, 2021 10:56
@deivid-rodriguez deivid-rodriguez merged commit fb12b85 into master Oct 13, 2021
@deivid-rodriguez deivid-rodriguez deleted the fix_install_crash branch October 13, 2021 12:16
deivid-rodriguez added a commit that referenced this pull request Oct 25, 2021
Fix install crash when lockfile has missing dependencies for the current platform

(cherry picked from commit fb12b85)
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.

bundle install fails with fresh rails 6 project using ruby 3.0.2 and Github Actions
2 participants