diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index 4b09d20073..0bbd2d9b75 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -109,7 +109,7 @@ module Bundler require "digest/sha2" checksum = ::Digest::SHA512.file(built_gem_path).hexdigest target = File.join(base, "checksums", file_name) - File.write(target, checksum) + File.write(target, checksum + "\n") Bundler.ui.confirm "#{name} #{version} checksum written to checksums/#{file_name}." end diff --git a/spec/bundler/bundler/gem_helper_spec.rb b/spec/bundler/bundler/gem_helper_spec.rb index f1bb9861cf..59feb5b8e9 100644 --- a/spec/bundler/bundler/gem_helper_spec.rb +++ b/spec/bundler/bundler/gem_helper_spec.rb @@ -172,7 +172,7 @@ RSpec.describe Bundler::GemHelper do it "calculates SHA512 of the content" do subject.build_checksum(Pathname(IO::NULL)) sha_path = app_path.join("checksums", "#{File.basename(IO::NULL)}.sha512") - expect(File.read(sha_path)).to eql(Digest::SHA512.hexdigest("")) + expect(File.read(sha_path).chomp).to eql(Digest::SHA512.hexdigest("")) end context "when build was successful" do