diff --git a/lib/bundler.rb b/lib/bundler.rb index 0b6f70d9df1..468d3b0a062 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -369,7 +369,7 @@ def requires_sudo? unwritable_files = files.reject {|f| File.writable?(f) } sudo_needed = !unwritable_files.empty? if sudo_needed - Bundler.ui.warn "Following files may not be writable, so sudo is needed: #{unwritable_files.map(&:to_s).join(",")}" + Bundler.ui.warn "Following files may not be writable, so sudo is needed:\n #{unwritable_files.map(&:to_s).join("\n ")}" end end diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb index 3e23f60f82b..0cc3bcd0324 100644 --- a/spec/bundler/bundler_spec.rb +++ b/spec/bundler/bundler_spec.rb @@ -320,12 +320,18 @@ def clear_cached_requires_sudo end context "unwritable paths" do before do - FileUtils.touch("tmp/vendor/bundle/unwritable.txt") - FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable.txt") + FileUtils.touch("tmp/vendor/bundle/unwritable1.txt") + FileUtils.touch("tmp/vendor/bundle/unwritable2.txt") + FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable1.txt") + FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable2.txt") end it "should return true and display warn message" do allow(Bundler).to receive(:bundle_path).and_return(Pathname("tmp/vendor/bundle")) - message = "Following files may not be writable, so sudo is needed: tmp/vendor/bundle/unwritable.txt" + message = <<-MESSAGE.chomp +Following files may not be writable, so sudo is needed: + tmp/vendor/bundle/unwritable1.txt + tmp/vendor/bundle/unwritable2.txt +MESSAGE expect(Bundler.ui).to receive(:warn).with(message) expect(Bundler.requires_sudo?).to eq(true) end