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 bundler/setup unintendedly writing to the filesystem #6814

Merged
merged 2 commits into from
Jul 12, 2023
Merged

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Jul 11, 2023

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

After #6786, bundler/setup would write to the filesystem when dealing with git sources.

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

When sorting and comparing git Gemfile vs lockfile sources during bundler/setup to figure out whether we need to re-resolve or not, we would try to find the default branch if nothing more specific was specified in the Gemfile.

If the git cache has been deleted though, that would fail.

The error would still be swallowed (and the branch would simply not be displayed), but trying to clone would still generate the side effect of creating the parent folder for the clone.

That could affect non-writable systems that don't expect bundler/setup to write to the filesystem at all.

To fix this, override Bundler::Source::Git#identifier to use exclusively static information, so it does not even try to clone the repo nor generate any side effects.

This is essentially a rework of the original attempt to fix #6743, but without the problems discussed in that PR.

Fixes #6813.

Make sure the following tasks are checked

@metaskills
Copy link

Thank you for doing this! I like the new test case. Were the other test failures random or from this change/fix?

Previously, when sorting and comparing git Gemfile vs lockfile sources during
`bundler/setup` to figure out whether we need to re-resolve or not, we
would try to find the default branch if nothing more specific was
specified in the Gemfile.

If the git cache has been deleted thought, that would fail.

The error would still be swallowed (and the branch would simply not be
displayed), but trying to clone would still generate the side effect of
creating the parent folder for the clone.

That could affect non-writable systems that don't expect `bundler/setup`
to write to the filesystem at all.

To fix this, override `Bundler::Source::Git#identifier` to use
exclusively static information, so it does not even try to clone the
repo nor generate any side effects.
@deivid-rodriguez
Copy link
Member Author

@metaskills They were directly related to this change. I pushed one more tweak that I expect to fix them 🤞.

@metaskills
Copy link

YUP! Looks green now. I really appreciate this followup. Is there anything I can do to help test/QA/etc?

@simi
Copy link
Member

simi commented Jul 12, 2023

YUP! Looks green now. I really appreciate this followup. Is there anything I can do to help test/QA/etc?

You can try to checkout related branch and add to path.

git clone git@github.com:rubygems/rubygems.git -b fix-git-cache /tmp/rubygems
ruby -I/tmp/rubygems/bundler/lib -r bundler/setup -e "puts Bundler::VERSION" 
2.5.0.dev

@metaskills
Copy link

Thanks! Confirmed working from my end.

@metaskills
Copy link

@simi !!!! How are you doing? Nice to see you around.

@simi simi merged commit 8e10600 into master Jul 12, 2023
92 checks passed
@simi simi deleted the fix-git-cache branch July 12, 2023 13:14
@simi
Copy link
Member

simi commented Jul 12, 2023

@simi !!!! How are you doing? Nice to see you around.

All good. :)

deivid-rodriguez pushed a commit that referenced this pull request Jul 12, 2023
Fix `bundler/setup` unintendedly writing to the filesystem

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

Issues with Bundler 2.4.16 Cache & Write Only Filesystems Git sources sorting isn't stable
3 participants