def lock(file)
contents = to_lock
contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")
return if @lockfile_contents == contents
if Bundler.settings[:frozen]
Bundler.ui.error "Cannot write a changed lockfile while frozen."
return
end
File.open(file, 'wb'){|f| f.puts(contents) }
rescue Errno::EACCES
raise Bundler::InstallError,
"There was an error while trying to write to Gemfile.lock. It is likely that \n" \
"you need to allow write permissions for the file at path: \n" \
"#{File.expand_path(file)}"
end