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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make bundle lock
always touch the lockfile in non-frozen mode
#7220
Make bundle lock
always touch the lockfile in non-frozen mode
#7220
Conversation
bundler/lib/bundler/definition.rb
Outdated
@@ -339,7 +339,10 @@ def lock(file, preserve_unknown_sections = false) | |||
|
|||
preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler)) | |||
|
|||
return if file && File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections) | |||
if file && File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections) | |||
FileUtils.touch(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I wrap this in a SharedHelpers.filesystem_access
block as well? 馃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that helper unifies error rescuing for filesystem access problems. Touch is a write to the filesystem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tell me what you think. Should we copy the frozen bundle check to guard the touch? I know for lock
it temporarily unfreezes because it's nonsensical otherwise, but this code path will run during install and update, I believe. We should not otherwise change the lockfile if frozen, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're referring to the little "Cannot write a changed lockfile while frozen" guard directly below, right? Yes, I also caught that and it seemed sensible not to touch the lockfile when frozen, but I did not add an explicit test about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I applied the wrapper. Anything else?
This is great! Thanks for working on this and thanks for including the test coverage. I added some questions inline and then this should be fairly simple to get merged. |
SharedHelpers.filesystem_access(file) {|p| FileUtils.touch(p) } | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would specifically return without touching the lockfile if the bundle is frozen, like so:
SharedHelpers.filesystem_access(file) {|p| FileUtils.touch(p) } | |
return | |
return if Bundler.frozen_bundle? | |
SharedHelpers.filesystem_access(file) {|p| FileUtils.touch(p) } | |
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd likewise add a test that it is not touched when frozen. Maybe here, since the lock command always temporarily unfreezes.
c8a9f1b
to
119d4bd
Compare
Hey @franzliedke, I decided to go ahead and merge this now since I want to see it make it into the 2.5.0 bundler release. I'll update with the test I was imagining. Thanks for your contribution! |
@martinemde Thanks! To be honest, I was hoping this would happen. 馃槄 I wasn't 100% sure about the implications in these other commands that I wasn't aware of. |
bundle lock
always touch the lockfile in non-frozen mode
Fixes #7120.
What was the end-user or developer problem that led to this PR?
In #7120, @hadmut mentioned problems with Make-based build pipelines:
Gemfile.lock
would not be "touched" (receive an updated file modification date) when runningbundle lock
is a no-op (i.e. the lockfile already matches theGemfile
).What is your fix for the problem, implemented in this PR?
An explicit
FileUtils.touch
call. 馃Make sure the following tasks are checked