summaryrefslogtreecommitdiff
path: root/lib/bundler/cli
diff options
context:
space:
mode:
authorVictor Gama <hey@vito.io>2022-09-21 15:09:36 -0300
committergit <svn-admin@ruby-lang.org>2022-10-03 20:41:45 +0900
commitbc6c1e0e25a9dc80382e2ffb8559bbe171e0400e (patch)
treed28b7e58e6b27c460072cdaec827129399a0a080 /lib/bundler/cli
parentb7a61cb485a9bfaa52107f57782e53365f4bf59a (diff)
[rubygems/rubygems] Copy template contents instead of file and perms
This allows the file to be created without copying permissions from Bundler's installation source. The previous behaviour was noticed after installing Ruby through brew, and using bundle init, which yielded a read-only Gemfile. https://github.com/rubygems/rubygems/commit/839a06851d
Diffstat (limited to 'lib/bundler/cli')
-rw-r--r--lib/bundler/cli/init.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/bundler/cli/init.rb b/lib/bundler/cli/init.rb
index e4f8229c48..bc96507c29 100644
--- a/lib/bundler/cli/init.rb
+++ b/lib/bundler/cli/init.rb
@@ -32,7 +32,11 @@ module Bundler
file << spec.to_gemfile
end
else
- FileUtils.cp(File.expand_path("../templates/#{gemfile}", __dir__), gemfile)
+ File.open(File.expand_path("../templates/#{gemfile}", __dir__), "r") do |template|
+ File.open(gemfile, "wb") do |destination|
+ IO.copy_stream(template, destination)
+ end
+ end
end
puts "Writing new #{gemfile} to #{SharedHelpers.pwd}/#{gemfile}"