When a Gemfile.lock created in Unix (with Unix-style line endings) is used in Windows, Bundler will always attempt to update Gemfile.lock such that it includes Windows line endings, even if there are no actual changes to make to the file.
Here's where the issue is:
definition.rb checks the Gemfile.lock contents with Windows line-endings against the contents of the file which (as I said) already has Unix line endings.
The code to convert windows line endings to Unix endings only runs after the files are compared. I'm not sure if this would cause other problems, but as far as I can tell, this would fix it:
# Convert to \r\n if the existing lock has them
# i.e., Windows with git config core.autocrlf=true
contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")
git config core.autocrlf=true
return if @lockfile_contents == contents
Gemfile.lock should not be touched if nothing has changed
This fixes issue #1105, Gemfile.lock always updated on Windows
when running bundle install
Good catch. Thanks. I've added failing specs and your fix to this pull request:
Closing since there's a merged pull request that claims to fix this issue.