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 edge case resulting in a crash when using zeitwerk inside a nested bundle exec invocation #4062

Merged
merged 2 commits into from Nov 18, 2020

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Nov 13, 2020

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

See #3270 for the realworld problem. It's a combination of using dependencies that monkeypatch Kernel.require, and using several levels of nested bundle execs.

When bundler's CLI is initialized, we check whether a custom Gemfile is configured, and in that case we invalidate the whole bundler environment so that the whole thing is reloaded using the new Gemfile. When we are inside a nested bundle exec, the original Gemfile is explicitly configured so that further subprocesses always use it, so we fall into this situation.

The problem is that we're resetting too much, and that can cause dependencies that further decorate Kernel.require to lose their decorations.

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

The fix is to only reset what we really need to reset here, namely, the settings so that they are reloaded using the new Gemfile as a base.

Fixes #3270.

Make sure he following tasks are checked

@deivid-rodriguez deivid-rodriguez marked this pull request as ready for review November 16, 2020 13:52
@deivid-rodriguez deivid-rodriguez changed the title Reset only settings when a custom gemfile is needed Fix edge case resulting in a crash when using zeitwerk inside a nested bundle exec invocation Nov 16, 2020
Only thing we need to reset is settings, and only because settings are
loaded relative to the `Gemfile`, so they need to be reset if the
configured or passed `Gemfile` is not standard and will resolve to a
different root.

Resetting more stuff causes issues under some circumstances,
specifically when dependencies further tweak `Kernel.require`.
@deivid-rodriguez deivid-rodriguez merged commit a9c77de into master Nov 18, 2020
@deivid-rodriguez deivid-rodriguez deleted the zeitwerk branch November 18, 2020 15:50
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
Fix edge case resulting in a crash when using `zeitwerk` inside a nested `bundle exec` invocation

(cherry picked from commit a9c77de)
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
Fix edge case resulting in a crash when using `zeitwerk` inside a nested `bundle exec` invocation

(cherry picked from commit a9c77de)
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
Fix edge case resulting in a crash when using `zeitwerk` inside a nested `bundle exec` invocation

(cherry picked from commit a9c77de)
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
Fix edge case resulting in a crash when using `zeitwerk` inside a nested `bundle exec` invocation

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

reverse_rubygems_kernel_mixin breaks require-extending libs
2 participants